如何检测当前的iOS是4.1还是4.2? [英] How to detect current iOS is 4.1 or 4.2?
本文介绍了如何检测当前的iOS是4.1还是4.2?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
检查iPhone iOS版本
我尝试使用此代码:
#if (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_2_2)
NSLog(@"iPhone 4.2");
#endif
但是当我在模拟器4.1上再次运行它时,我仍然得到日志控制台中的iPhone 4.2。
but when I run it again on simulator 4.1, I still get the log "iPhone 4.2" in console.
感谢您的帮助。
Tung Do
推荐答案
您应该完全避免询问系统版本。
You should probably avoid asking about the system version altogether.
更好的设计会问关于特定功能。
A better design would ask about a specific feature.
例如: if(NSClassFromString(@UIPrintInfo))
会告诉你是否当前设备支持打印API,可在4.2或更高版本中使用。
For instance: if (NSClassFromString(@"UIPrintInfo"))
would tell you if the current device supports the printing API,available in 4.2 or higher.
这样您可以计划代码以使用功能(如果可用),而不是基于操作系统版。
That way you can plan your code to use a feature if it's available, on not based on the OS version.
这篇关于如何检测当前的iOS是4.1还是4.2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文