Raptor
Raptor

Reputation: 54212

iOS 8 SDK: [UIImage imageNamed:] issue

In previous iOS SDK, [UIImage imageNamed:] can determine the image to load automatically without giving the file extension, for example:

[ivTest setImage:[UIImage imageNamed:@"testImage"]];

It will search for appropriate image to load (i.e. testImage.jpg & [email protected]). But for iOS 8, it sometimes cannot identify the correct image to load, and just returns null.

I have to specify the extension:

[ivTest setImage:[UIImage imageNamed:@"testImage.jpg"]];

But this happens only in same rare cases.

Given that I have only the following images in the project:

No other images with similar names. How can I prevent this? Should I specify extension for all my imageNamed: ?

Upvotes: 1

Views: 1305

Answers (1)

KudoCC
KudoCC

Reputation: 6952

Reference from here

On iOS 4 and later, if the file is in PNG format, it is not necessary to specify the .PNG filename extension. Prior to iOS 4, you must specify the filename extension.

So the answer is you have to specify the filename extension for all JPEG.

About Asset Catalog, well, to tell the truth I don't have any ideas about that, let's study it later.

Upvotes: 3

Related Questions