
Question:
Apple says you must have @2x versions of your images and use a stuff like
UIImage* anImage = [UIImage imageNamed:@"Button"]; // without the extension
That will select the lowres and hires versions of Button image, depending on the iPhone version (3G/3GS or 4). But what if the app is for iPad too?
Will the iPad load the Button image even if I don't specify the extension?
thanks.
Solution:1
Either
UIImage* anImage = [UIImage imageNamed:@"Button"]; // without the extension
or
UIImage* anImage = [UIImage imageNamed:@"Button.png"]; // with the extension
will work on iOS4, since apple basically discourage you from using any other image than PNG you can omit the exertion.
Both work for @2x.png files as well. Make sure the @2x files have been added to your project.
Solution:2
Will the iPad load the Button image even if I don't specify the extension?
No. From the doc:
-
Special Considerations
On iOS 4 and later, the name of the file is not required to specify the filename extension. Prior to iOS 4, you must specify the filename extension.
Since iPad is running 3.2, you need to include the .png
part. However, writing
UIImage* anImage = [UIImage imageNamed:@"Button.png"];
will not prevent the system from finding Button@2x.png
on 4.0.
Solution:3
as a complement to the answer, I must mention this page:
the problem is that the SDK is broken and despite Apple mentioning that other methods beyond imageNamed load the @2x images, they don't. Shame on Apple to make us lose time when their SDK is broken.
the mentioned link has the solution for the problem, using a way around.
Solution:4
Yes, it will load the standard (lores) version.
Edit: Don't forget to test on the simulator or real device, as there are some twiddles, but imageNamed: has proven to work well so far.
Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
EmoticonEmoticon