码迷,mamicode.com
首页 > 移动开发 > 详细

iOS 系统版本的判断

时间:2017-01-11 10:10:37      阅读:504      评论:0      收藏:0      [点我收藏+]

标签:text   simulator   hone   技术分享   device   tde   mac   imu   define   

 iOS 宏定义系统版本的判断

#define iOS7 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
#define iOS7Later ([UIDevice currentDevice].systemVersion.floatValue >= 7.0f)
#define iOS8Later ([UIDevice currentDevice].systemVersion.floatValue >= 8.0f)
#define iOS9Later ([UIDevice currentDevice].systemVersion.floatValue >= 9.0f)
#define iOS9_1Later ([UIDevice currentDevice].systemVersion.floatValue >= 9.1f)
#define iOS10_1Later ([UIDevice currentDevice].systemVersion.floatValue >= 10.1f)
 
很多人都是用的这种方法,在此之前我也用的这种宏定义的方法,但是在xcode的开发环境中已经定义好了很多 系统版本判别的宏定义 包含iOS 、 Mac、TVOS、WATCHOS的系统版本的宏,截图如下:
  
技术分享

 

 
只要在使用时 用下面的方法就可以了
 
#ifdef __IPHONE_7_0
  //iOS7的新特性代码
#endif
 
或者是使用:
 
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_7_0
 
  //iOS7的新特性代码
#endif(__IPHONE_OS_VERSION_MAX_ALLOWED 这个定义是在Simulator-IOS7.0/usr/include/AvailabilityInternal.h文件中)
 
就搞定了。

 

iOS 系统版本的判断

标签:text   simulator   hone   技术分享   device   tde   mac   imu   define   

原文地址:http://www.cnblogs.com/Rong-Shengcom/p/6272460.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!