Objective-C Versions of iPhone and Screen Sizes

Hello,

this article: that will tell code scripts of iPhone, which screen, which version, which model.

First Delegate file our .h file @interface before we add the following lines;

#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_IPHONE_4 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 480.0)
#define IS_IPHONE_5 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 568.0)
#define IS_IPHONE_6 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 667.0)
#define IS_IPHONE_6_PLUS (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 736.0)
#define IS_RETINA ([[UIScreen mainScreen] scale] == 2.0)
#define IOS_VERSION [[[UIDevice currentDevice] systemVersion] floatValue]

Then we'll add that we want to use our .m or .h file.

Usually we import file header .h file.

Sample;

#import "AppDelegate.h"

Examples of our .m file for later use;

if(IS_IPHONE_4) {
 // Processes for iPhone 4
} else if(IS_IPHONE_5) {
 // Processes for iPhone 5
} else if (IS_IPHONE_6) {
 // Processes for iPhone 6
} else if (IS_IPHONE_6_PLUS) {
 // Processes for iPhone 6 Plus
}

if(IS_IPAD) {
 // Processes for iPad
}

if(IS_IPHONE) {
 // Processes for iPhone
}

if (IS_RETINA) {
 // Retina or Normal check
}

if(IOS_VERSION == 8.00) {
 // iOS 8, 7 vb.
}

This expression used in devices iPhone, iPad / iPhone for iphone 4, 5, 6, 6plus control / version control and iOS is the retina shows the control.

Share this Post

0 comments to Objective-C Versions of iPhone and Screen Sizes

    Leave a Reply

    grin LOL cheese smile wink rolleyes confused surprised big surprise tongue laugh tongue rolleye tongue wink hmmm mad angry zipper kiss cool smile question dil