这段代码最简单:
1 2 3 4 |
if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ) { return YES; /* Device is iPad */ } |
1 2 3 4 5 6 7 8 9 |
//这是定义成宏的版本 #define IDIOM UI_USER_INTERFACE_IDIOM() #define IPAD UIUserInterfaceIdiomPad if ( IDIOM == IPAD ) { /* do something specifically for iPad. */ } else { /* do something specifically for iPhone or iPod touch. */ } |
1 2 3 4 |
//还有另一种方法 if ( [(NSString*)[UIDevice currentDevice].model hasPrefix:@"iPad"] ) { return YES; /* Device is iPad */ } |