参考自:http://www.cocoachina.com/iphonedev/sdk/2010/1015/2192.html
以下代码由 CocoaChina 版主 “cclv” 分享,可用于判断应用运行的设备是否是 iPad
#define isPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
在 FBConnect 的库里面我也发现了类似的用法:
static BOOL FBIsDeviceIPad() {
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 30200
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
return YES;
}
#endif
return NO;
}
还有另外一种判断方法如下:
NSString* strDevice = [[UIDevice currentDevice].model substringToIndex:4];
if ([strDevice isEqualToString:@"iPad"]) {
isIpad_ = YES;
} else {
isIpad_ = NO;
}