1

Possible Duplicate:
How to detect iPhone 5 (widescreen devices)?

We can differentiate iPad and iPhone using

UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone/UIUserInterfaceIdiomPad

But how to differentiate between iPhone 4 and iPhone 5 according to the user

Community
  • 1
  • 1
Teja Swaroop
  • 1,139
  • 12
  • 18

1 Answers1

5

Quoting this post:

#define IS_IPHONE_5 ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON )

Then simply check with:

if( IS_IPHONE_5 )
{}
else
{}

Mind you, you don't have to define this as a macro if you don't want to. Simplified version:

if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) {
    if ([[UIScreen mainScreen] bounds].size.height == 568) {
        //5
    }else{
        //not 5
    }
}else{
    //iPad
}

And yes this works in landscape. Even though the orientation of the device has changed, the devices height remains the same. Getting the height of UIScreen is different then for example getting the height of a view.

Community
  • 1
  • 1
Mick MacCallum
  • 129,200
  • 40
  • 280
  • 281