4

In the Xcode I have like this:

screenshot

In a MyViewController.m I am loading the image and nicely it is loaded the @2x when needed ( on retina)

tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"emptyList.png"]];

I would like to add another file which would be loaded only on the iPhone 5's 4" screen. Is that possible? How can I do it?

1 Answers1

8

The question is not very clear but what I am assuming you are asking is: What is the naming convention for iPhone 5 specific images?

We already know we can target iPad/iPhone and the retina/standard display of those devices using the:

.png
@2x.png
~iphone.png
~ipad.png

etc.

Well the question about iPhone 5 specific images has been discussed at length on the Apple Developer Forums, and it's clear there is no way to do this.

Notably, one clue was that the Default.png file to trigger 4" compatible apps had to be named Default-568h@2x.png which triggered a lot of devs thinking that adding the suffix "-568h@2x.png" was the way to go. It's not. You can find this discussion here on the Apple Developer Forums.

Usually people look for this as a solution hoping to adapt for the larger screen with larger images. However, you should implement iOS 6's AutoLayout feature. Remember the iPhone 5's OS is at min iOS 6, you can also implement your layout with springs and struts otherwise.

This should be sufficient for scaling to the larger screen. If you wish to have a different layout altogether for the larger screen, you can detect the screen size and adapt accordingly. You can also specify in Xcode a different nib file to use on the 4" screen. Hope this helps.

More info on this thread from the Apple Developer Forums.

Daniel
  • 23,129
  • 12
  • 109
  • 154
  • 2
    +1 nice answer, but I need to add support for an existing project ( ios5 and iphone3, iphone4) to ios6, iphone5 and hold the others. I am not sure I can use the AutoLayout, because I can't drop the ios5 support. Using the same xib file, will result a messy code, where I am checking if I am on a 4" device or just a smaller one, new xib files seems to be the best options. Thanks –  Oct 03 '12 at 15:28
  • Sure, new files is the way for you in this situation. I updated a few of my apps, I didn't change the design for the taller screen, and I didn't use nibs in those projects, it was a case of adjusting the height of my root view controllers etc I should have used `autoresizeMask` on my views but I didn't. This is what I mean by springs and struts, make anything you can autosize to the superview. You don't need to provide iPhone 5 specific images as a general rule. – Daniel Oct 03 '12 at 15:33