Possible Duplicate:
How to detect iPhone 5 (widescreen devices)?
Is there a way I can detect if the current device is the iphone 5? More specifically if it's using the new 4" screen?
Possible Duplicate:
How to detect iPhone 5 (widescreen devices)?
Is there a way I can detect if the current device is the iphone 5? More specifically if it's using the new 4" screen?
Use this
#define IS_IPHONE5 (([[UIScreen mainScreen] bounds].size.height-568)?NO:YES)
I think you should concentrate on preferred display mode, rather than detecting iPhone5. Who knows what devices Apple will manufacture, but if your software supports that mode, it will be futureproof.
BOOL isiPhone5 = CGSizeEqualToSize([[UIScreen mainScreen] preferredMode].size,CGSizeMake(640, 1136));
In the future, folks might want to change preferred display mode on the fly. For example disconnect AppleTV from 720p tv and plug to 1080p, without restarting the app of course.
if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){
if(UIScreenOverscanCompensationScale==1136/640){
//move to your iphone5 storyboard
[UIStoryboard storyboardWithName:(NSString *) bundle (NSBundle *)];
}
else{
//move to your iphone4s storyboard
[UIStoryboard storyboardWithName:(NSString *) bundle (NSBundle *)];
}
}
This was an answer posted by me in another question here.
Add this code to your application:
if ([UIScreen mainScreen].scale == 2.f && screenHeight == 568.0f)
{// iPhone 5 code}
else
{// previous version code}