1
votes

My application, which should support iOS 5.0+ I have background UIImage, which should be load proper image depending on device. So I've created 5 images with corresponding resolutions.

Also I've set [email protected] splash image. I then detect in viewDidLoad which device my app is running and use

[bkgImageView setImage:[UIImage imageNamed:@"img.png"]];

to load appropriate image. All resolutions are loading just fine except iPhone 4" one, which is [email protected]. If I load this one explicitly

[bkgImageView setImage:[UIImage imageNamed:@"[email protected]"]];

the scale is not correct. So how can I load 4" retina image automagically or manually?

1
Did you check the size on the image view to make sure that it's sized correctly?Mike M
@Mike M: I don't stretch image in the view, it's set to Center. So I don't think it's related.Pablo
What I meant was, what is the size of bkgImageView? (I guess you're expecting it would clip if too small?)Mike M
The size of frame is 320x568. The [email protected] is twice bigger. Right now it's clipping if I load explicitly.Pablo
This issue has been discussed to the end in following link. See if its useful stackoverflow.com/questions/12431445/…Anupdas

1 Answers

2
votes

Adding -568h to the end of the file name doesn't work. The only supported modifiers are @2x,~ipad, and ~iphone. The only case where -568h might seem to work is the launch image, where the image must be specifically named [email protected].

You should use auto layout (or struts and springs) to adjust your screen accordingly.

Your problem is that it's automatically stretching an image that's already large enough.

The solution:

If you load the image explicitly for that device, you should load "image-568h", and let it automatically add the @2x. That way, it knows that it's a high resolution image and doesn't attempt to stretch it.

Additionally, rather than detect the device, you could design the image with the extra space at the bottom to fit the 4" screen, set the image to Aspect Fill, and let it clip for smaller devices.