判断iPhone还是iPad设备


1. 用[UIDevice currentDevice].model,这个返回的是一个NSString,你可以做如下判断就能知道设备是iPad还是iPhone.


if ([[UIDevice currentDevice].model rangeOfString:@"iPad"].location != NSNotFound) {
    NSLog(@"This is an iPad!");
}

2. 用UI_USER_INTERFACE_IDIOM()方法,这是系统定义的一条宏。使用方法也很简单。

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
    NSLog(@"This is an iPad!");
}
 
 
转自:http://blog.sina.com.cn/s/blog_3f88614f0100sdcm.html
posted @ 2016-02-25 11:49  索马里猫  阅读(226)  评论(0编辑  收藏  举报