转载自: http://www.tuicool.com/articles/JJzIBn
//检测设备
-(bool)checkDevice:(NSString*)name
{NSString* deviceType = [UIDevice currentDevice].model;
NSLog(@"deviceType = %@", deviceType);
NSRange range = [deviceType rangeOfString:name];
return range.location != NSNotFound;
}
//此处为调用检测函数
NSString * nsStrIphone=@"iPhone";
NSString * nsStrIpod=@"iPod";
NSString * nsStrIpad=@"iPad";
bool bIsiPhone=false;
bool bIsiPod=false;
bool bIsiPad=false;
bIsiPhone=[self checkDevice:nsStrIphone];
bIsiPod=[self checkDevice:nsStrIpod];
bIsiPad=[self checkDevice:nsStrIpad];
注:网上有的说的这个方法 [[UIDevice currentDevice] userInterfaceIdiom]==UIUserInterfaceIdiomPad 貌似只是判断程序是否是ipad程序,但如果是iphone程序,在ipad上运行的话一样不会返回YES ,所以用了上边的方法来判断设备是否是ipad 仍有待考证chenyong