Skip to content

Instantly share code, notes, and snippets.

@syxc
Created April 16, 2013 07:00
Show Gist options
  • Select an option

  • Save syxc/5393921 to your computer and use it in GitHub Desktop.

Select an option

Save syxc/5393921 to your computer and use it in GitHub Desktop.
How to check iPhone Device Version in iOS?
// via http://stackoverflow.com/a/13068238/1242183
#define HEIGHT_IPHONE_5 568
#define IS_IPHONE ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
#define IS_IPHONE_5 ([[UIScreen mainScreen] bounds ].size.height == HEIGHT_IPHONE_5 )
// then just check whenever you needs..
if (IS_IPHONE_5) {
// Code for iPhone5
} else {
// Code for earlier version
}
@syxc
Copy link
Author

syxc commented Apr 16, 2013

IOS SDK Check if device is an iPhone or iPad at runtime

This is the code i use to check if the user device is an iPhone, iPhone4 or IPad. Based on this i show different screens.

// check the device type - iphone / ipad / ipod / whatever
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
         if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] == YES &&
             [[UIScreen mainScreen] scale] == 2.00) {
                 // RETINA DISPLAY CODE
         } else {
             // NON RETINA DISPLAY CODE
         }
} else {
    // IPAD CODE HERE
}

via http://www.adriancoroian.com/programming-ios-sdk-check-if-device-is-an-iphone-or-ipad-at-runtime/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment