Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check iPhone Device Version in iOS?

Tags:

ios

iphone-5

Hi i would like to check iPhone Device Version in iOS.

I mean , currently running device is iPhone 4 or iPhone 5.

I need to check the device , is that iPhone 5 or not?

Because i have some problem in my app that need to know iPhone 5 or not.

So how can i?

like image 438
Fire Fist Avatar asked Nov 29 '22 08:11

Fire Fist


1 Answers

Add this code:

if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){
        if ([[UIScreen mainScreen] respondsToSelector: @selector(scale)]) {
            CGSize result = [[UIScreen mainScreen] bounds].size;
            CGFloat scale = [UIScreen mainScreen].scale;
            result = CGSizeMake(result.width * scale, result.height * scale);

            if(result.height == 960) {
                NSLog(@"iPhone 4 Resolution");
                resolution_number = 1;
            }
            if(result.height == 1136) {
                NSLog(@"iPhone 5 Resolution");
            }
        }
        else{
            NSLog(@"Standard Resolution");
        }
    }
like image 132
dbramhall Avatar answered Dec 09 '22 03:12

dbramhall