Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

To detect IOS device type

I have found the solutions from here: Determine device (iPhone, iPod Touch) with iPhone SDK

From the link, it suggests to use the library https://gist.github.com/1323251

But obviously the library is quite outdated. I couldn't find the iPhone 5 and new iPad and etc in the list.

Does anyone know how can I find the completed and updated list?

Thank you so much.

like image 327
Sam YC Avatar asked Jan 17 '13 05:01

Sam YC


1 Answers

Just adding to @Mohammad Kamran Usmani answer. More specific iPhone types:

@import UIKit;

//Check which iPhone it is
double screenHeight = [[UIScreen mainScreen] bounds].size.height;
if(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad)
{
    NSLog(@"All iPads");
} else if (UI_USER_INTERFACE_IDIOM()== UIUserInterfaceIdiomPhone)
{
    if(screenHeight == 480) {
        NSLog(@"iPhone 4/4S");
        smallFonts = true;
    } else if (screenHeight == 568) {
        NSLog(@"iPhone 5/5S/SE");
        smallFonts = true;
    } else if (screenHeight == 667) {
        NSLog(@"iPhone 6/6S");
    } else if (screenHeight == 736) {
        NSLog(@"iPhone 6+, 6S+");
    } else {
        NSLog(@"Others");
    }
}
like image 106
Mukund Agarwal Avatar answered Nov 10 '22 00:11

Mukund Agarwal