如何检测iPhone应用程序是否在iPhone 4设备上运行?
问题描述:
我尝试更新iPhone应用程序以支持iPhone 4上的较大屏幕分辨率。如何检测我的应用程序是否在iPhone 4上运行?如何检测iPhone应用程序是否在iPhone 4设备上运行?
在此先感谢。
答
我可以通过这个代码追踪我的iPhone 3GS
struct utsname systemInfo;
uname(&systemInfo);
NSLog(@"%@", [NSString stringWithCString:systemInfo.version
encoding:NSUTF8StringEncoding]);
我希望它会为iPhone工作4
答
你可以尝试使用这种方法
-(NSString *) getDeviceType {
return [UIDevice currentDevice].model;
}
或者只是得到它像这个:
NSLog(@"%@", [UIDevice currentDevice].model);
要检查设备是否能够视网膜做到以下几点:
BOOL result;
if ([[UIScreen mainScreen] scale] == 2.0) result = TRUE; else result = FALSE;
见http://stackoverflow.com/questions/1964776/determine-current-iphone-os-version-at-runtime-and-compare -version-strings – 2010-06-09 07:19:04
据我所知,这不是同一个问题。他不是问操作系统版本,而是设备版本(例如iPhone 3G或iPhone 4)。这在UIDevice类currenty中不能被查询。适用于iOS 4的SDK可能有解决方案,但这仍将处于NDA之下。 – Alfonso 2010-06-09 07:33:14
您是否可以让您的应用通过检查窗口/根视图框的大小来检测屏幕大小? – Joe 2010-06-09 10:47:03