5

I have an iOs app with full screen gradient background. Now, with iphone 5 size of screen is different and of course I would like to support both 5th and 4th devices.

What is recommended way to do it?

Alan Harper
  • 793
  • 1
  • 10
  • 23

1 Answers1

1

From the post I linked to in the comment

#import <sys/utsname.h>

NSString*
machineName()
{
struct utsname systemInfo;
uname(&systemInfo);

return [NSString stringWithCString:systemInfo.machine
                          encoding:NSUTF8StringEncoding];
}

The result should be:

@"i386"      on the simulator
@"iPod1,1"   on iPod Touch
@"iPod2,1"   on iPod Touch Second Generation
@"iPod3,1"   on iPod Touch Third Generation
@"iPod4,1"   on iPod Touch Fourth Generation
@"iPhone1,1" on iPhone
@"iPhone1,2" on iPhone 3G
@"iPhone2,1" on iPhone 3GS
@"iPad1,1"   on iPad
@"iPad2,1"   on iPad 2
@"iPhone3,1" on iPhone 4
@"iPhone4,1" on iPhone 4S

I'm assuming this will return something like @"iPhone5,1" for the latest model. Then just do a check like

NSString *iphoneType = machineName();
if ([iphoneType isEqualToString@"iPhone5,1"]){
    //image for iphone 5
} else {
           //image for the rest
}

Let me know if that works out

jer-k
  • 1,413
  • 2
  • 12
  • 23
  • 1
    Program way is clear. May it there is something "Approved by Apple"? Like having images with @xxx name, etc – Alan Harper Sep 28 '12 at 01:01
  • Are you saying that the whole background is an image? – jer-k Sep 28 '12 at 16:00
  • Take a look at this thread. http://stackoverflow.com/questions/1108859/detect-the-specific-iphone-ipod-touch-model there is an answer by Will Harris that will be what you want. I'm going to edit my answer, but the credit is due to him. – jer-k Oct 01 '12 at 17:01