如何以编程方式检测iOS设备 [英] How to detect iOS device programmatically
本文介绍了如何以编程方式检测iOS设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要知道哪个iOS设备正在运行应用程序(更准确地说我需要知道的是设备armv6或armv7)。 UIUserInterfaceIdiomPad()无法检查设备是iPhone4S还是iPhone3G。有可能吗?
I need to know which iOS device is currently running app (saying more exactly I need to know is device armv6 or armv7). UIUserInterfaceIdiomPad() could not check is device an iPhone4S or iPhone3G. Is it possible?
推荐答案
下载 https://github.com/erica/uidevice-extension (UIDevice-Hardware类),你可以使用这些:
Download https://github.com/erica/uidevice-extension (UIDevice-Hardware class) and you can use these:
[UIDevice currentDevice] platformType] // returns UIDevice4GiPhone
[[UIDevice currentDevice] platformString] // returns @"iPhone 4G"
或检查其视网膜
+ (BOOL) isRetina
{
if([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
return [[UIScreen mainScreen] scale] == 2.0 ? YES : NO;
return NO;
}
或查看iOs版本
+ (BOOL) isIOS5
{
NSString *os5 = @"5.0";
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
// currSysVer = @"5.0.1";
if ([currSysVer compare:os5 options:NSNumericSearch] == NSOrderedAscending) //lower than 4
{
return NO;
}
else if ([currSysVer compare:os5 options:NSNumericSearch] == NSOrderedDescending) //5.0.1 and above
{
return YES;
}
else // IOS 5
{
return YES;
}
return NO;
}
这篇关于如何以编程方式检测iOS设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文