How to check that device is iPhone 5

There is no function in iOS 6 that can tell us that app is running on device with tall screen. So we have to check device’s screen size manually.

 

+ (BOOL) isTallScreen {
CGFloat height = [UIScreen mainScreen].bounds.size.height;
CGFloat scale = 1;
if ([ [UIScreen mainScreen] respondsToSelector: @selector(scale)] == YES) {
scale = [ [UIScreen mainScreen] scale];
}

return ( (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) && ( (height * scale) >= 1136) );
}

tips & tricks

Join 7,715 other subscribers

interview questions


Algorithm Android Android Studio API APP Programming Apps AS400 blogging Browser CheatSheets Config CSS DATABASE dsa error Features GUI HTML HTML5 IDE installation Interview Questions IOS iPhone javascript Mac objective-c OneDrive OS Programming quicktips SDK SEO Settings SMO SQL swift swiftUI Teams Tips & Tricks Tools UI Web Wordpress Xcode


Archives

Leave a Reply

Your email address will not be published. Required fields are marked *

Discover more from CODE t!ps

Subscribe now to keep reading and get access to the full archive.

Continue reading