views:

158

answers:

3

I have 3 images on the same place on my app's bundle: "image~iphone.png", "image@2x~iphone.png" and "image~ipad.png".

when I do

UIImage *imageU = [UIImage imageNamed:[[NSBundle mainBundle]  pathForResource:@"image"
ofType:@"png"]];

BOth, the iPhone and iPhone 4 hires versions load fine, but not the ipad image. When I run on iPad, I get nil on imageU.

Yes, the image is there, the name is correct (iphone~ipad.png).

Why is that? any clues?

thanks.

A: 

Possible daft attempt, but is the ipad image copied into the correct target when you add it as a resource? By that, I mean - of you right click the image and get info, does it have the iPad ticked as it's target?

davbryn
yes. Checked them out again now. All perfectly assigned to the correct target.
Digital Robot
+1  A: 

I discovered that the solution for that is: do not use any extension on the iPad images. This tilde trick is not working for iPad. One more buggy stuff that makes us waste time.

Digital Robot
+1  A: 

I ran into the same problem with launch images. Despite what the docs say, naming a file with a ~ipad suffix doesn't do anything. You need to set the UILaunchImageFile~ipad key and use a separate name for your launch images on iPad, e.g., DefaultiPad.png and DefaultiPad-Landscape.png, then make sure to just set UILaunchImageFile~ipad to DefaultiPad (no .png suffix) and it will pick up the variants correctly.

Tony