Identify ipad device

I am writing a universal application for iphone and ipad. How to determine if an iPad device. I used this link to determine the type of iPhone (3G, 3GS).

Identify your device (iPhone, iPod Touch) with iPhone SDK

+3
source share
5 answers

Brad's solution is absolutely correct. If you are creating a universal application designed to work on iPhone with an older OS, as well as with modern iPads and iPhones, you might want to add this code to catch situations where the idiom is not defined.

// If iPhoneOS is 3.2 or greater then __IPHONE_3_2 will be defined
#ifndef __IPHONE_3_2    

typedef enum {
    UIUserInterfaceIdiomPhone,           // iPhone and iPod touch
    UIUserInterfaceIdiomPad,             // iPad
} UIUserInterfaceIdiom;

#define UI_USER_INTERFACE_IDIOM() UIUserInterfaceIdiomPhone

#endif // ifndef __IPHONE_3_2
+4
source

, iPad, , . , , , (, , ).

, , iPad, , . Apple , :

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
    // iPad-specific interface here
}
else
{
    // iPhone and iPod touch interface here
}
+33

, :

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
    //iPhone methods
}
else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
    //iPad methods
}
+2

try it

     if([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad)
        {
            // etc.
        }
     else
        {
        //iphone
         }
+1
source
if ( [(NSString*)[UIDevice currentDevice].model isEqualToString:@"iPad"] ) {
            NSLog(@"...in iPad");         
} else {
            NSLog(@"...in iPhone/iPod");              
}
0
source

Source: https://habr.com/ru/post/1753683/


All Articles