判斷系統(tǒng)版本是我們經常用到的,尤其是現(xiàn)在大家都有可能需要適配iOS 10,那么問題就出現(xiàn)了,如下圖:
我們得到了答案是:
//值為 1
[[[[UIDevice currentDevice] systemVersion] substringToIndex:1] integerValue]
//值為10.000000
[[UIDevice currentDevice] systemVersion].floatValue,
//值為10.0
[[UIDevice currentDevice] systemVersion]
所以說判斷系統(tǒng)方法最好還是用后面的兩種方法沈贝,哦~我忘記說了[[UIDevice currentDevice] systemVersion].floatValue這個方法也是不靠譜的,好像在8.3版本輸出的值是8.2勋乾,記不清楚了反正是不靠譜的宋下,所以建議大家用[[UIDevice currentDevice] systemVersion]這個方法!
Swift判斷如下:
if #available(iOS 10.0, *) {
// iOS 10.0
print("iOS 10.0");
} else { }