Determining What Kind Of iPhone The User Uses [CODES]

In my last post, I already posted this piece of codes. The code is not mine, and is from the answer on stackoverflow. I am too lazy right now to copy my own code from my project/Xcode. So, how can your app determine what kind of iPhone your user uses? There are many ways to do that, one of those is getting your screen bounds.

You can see here that the iPhone 5 and iPhone5s have the same length of screen.

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {

    CGSize result = [[UIScreen mainScreen] bounds].size;

    if (result.height == 480) {
        // 3.5 inch display - iPhone 4S and below
        NSLog(@"Device is an iPhone 4S or below");

    else if (result.height == 568) {
        // 4 inch display - iPhone 5
        NSLog(@"Device is an iPhone 5/S/C");

    else if (result.height == 667) {
        // 4.7 inch display - iPhone 6
        NSLog(@"Device is an iPhone 6");

    else if (result.height == 736) {
        // 5.5 inch display - iPhone 6 Plus
        NSLog(@"Device is an iPhone 6 Plus");

else if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
       // iPad 9.7 or 7.9 inch display.
       NSLog(@"Device is an iPad.");
So it is pretty easy, right? If you find this post helpful, please share and subscribe.

Post a Comment