1

Currently I'm defining my app's background image in XCode's Attribute Inspector under Image View.

My view in Attributes Inspector

I'd like to, however, use a different background when an iPhone 5 views the app -- this is for a gaming app so certain screens have tables that I want to make longer. I know this has been written about a lot and some if/then statements are required. My question is: If I've already defined the background image using the Attribute Inspector, is there code to overwrite that which I can add to my .h and .m files?

Here's what I'm thinking: This is the code I'd add to my AppDelegate file:

#define IS_WIDESCREEN (fabs((double)[[UIScreen mainScreen]bounds].size.height - (double)568) < DBL_EPSILON)
#define IS_IPHONE ([[[UIDevice currentDevice]model] isEqualToString:@"iPhone"])
#define IS_IPOD   ([[[UIDevice currentDevice]model] isEqualToString:@"iPod touch"])
#define IS_IPHONE_5 (IS_IPHONE && IS_WIDESCREEN)

This is the code I'd use in my .m file:

if(IS_IPHONE_5) {

    } else {      

}

So here really is what I'm looking for:

  1. Where do I put this code -- do I have to define a new (void) statement?
  2. What code do I use between the { } to call that new image and tell it to display as the background?
Popeye
  • 11,839
  • 9
  • 58
  • 91
user1506841
  • 65
  • 1
  • 9
  • 1
    Please tag your question correctly. What did this have to do with the `xcode IDE` and `Apple`? The answer - nothing. Please look at the info section of the tag before tagging. Will benefit you in the short and long run. – Popeye Dec 24 '12 at 14:04
  • This is not an issue with the `xcode IDE` so should not have the `xcode` tag please do not use it. Its should only be used with issues related to the IDE and not thinks that you are using it for such as coding creating interfaces, they all have there own tags. Please tag correctly. – Popeye Dec 24 '12 at 14:21
  • There are also many questions that have asked this including two that I have already answered here is the latest. http://stackoverflow.com/questions/13399075/screen-size-of-iphone-5/13399220#13399220 – Popeye Dec 24 '12 at 14:22
  • 1
    Take a look at [the macro in this answer](http://stackoverflow.com/a/12563412/486845) to a similar question. It will simplify things a lot. You are on the right track, however. Using different images on iPhone 5 and other iPhones are not as simple as one could wish it to be. – simonbs Dec 24 '12 at 14:53

1 Answers1

1

simply take the image you want to display instead of your already existant a "HomeBG-568h@2x.png" with size 640 x 1136 so xcode will automatically use that image when the device is an iphone 5 anywhere your app calls for the "HomeBG.png" image. Hope that helps!

Yo_Its_Az
  • 2,043
  • 2
  • 18
  • 25
  • While this applies to retina images (@2x and @2x~ipad), I'm afraid it does not apply to iPhone 5 images. However, when adding a Default-568h@2x.png your app is considered iPhone 5 optimized. The author of the original question should [look at the macro in this answer](http://stackoverflow.com/a/12563412/486845). It simplifies things a lot. – simonbs Dec 24 '12 at 14:50