IOS 10 中版本的判断
来源:互联网 发布:淘宝好评怎么修改 编辑:程序博客网 时间:2024/05/19 17:06
#define IsIOS7 ([[[[UIDevice currentDevice] systemVersion] substringToIndex:1] intValue]>=8.0)。
//在iOS10 下 不能用了
[[[[UIDevice currentDevice] systemVersion] substringToIndex:1] intValue]//会永远返回 1
可以尝试使用一下方法:
//等于#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)//大于#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)//大于等于#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)//小于#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)//小于等于#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
或者使用:
if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){.majorVersion = 9, .minorVersion = 1, .patchVersion = 0}]) { NSLog(@"Hello from > iOS 9.1");}if ([NSProcessInfo.processInfo isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){9,3,0}]){ NSLog(@"Hello from > iOS 9.3");}
或者使用:
if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_9_0) { // do stuff for iOS 9 and newer} else { // do stuff for older versions than iOS 9}
if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) {} else{ #if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_8_0 #endif}
有时候会缺少一些常量,NSFoundationVersionNumber是在NSObjCRuntime.h中定义的,作为Xcode7.3.1的一部分,我们设定常熟范围从iPhone OS 2到#define NSFoundationVersionNumber_iOS_8_4 1144.17,在iOS 10(Xcode 8)中,苹果补充了缺少的数字,设置有未来的版本.
#define NSFoundationVersionNumber_iOS_9_0 1240.1#define NSFoundationVersionNumber_iOS_9_1 1241.14#define NSFoundationVersionNumber_iOS_9_2 1242.12#define NSFoundationVersionNumber_iOS_9_3 1242.12#define NSFoundationVersionNumber_iOS_9_4 1280.25#define NSFoundationVersionNumber_iOS_9_x_Max 1299
Swift中这样写:
if NSProcessInfo().isOperatingSystemAtLeastVersion(NSOperatingSystemVersion(majorVersion: 10, minorVersion: 0, patchVersion: 0)) { // 代码块}或者使用if #available(iOS 10.0, *) { // 代码块} else { // 代码块}
0 0
- IOS 10 中版本的判断
- 程序中如何判断iOs的版本
- 判断设备及iOS版本的宏
- ios版本和设备类型的判断
- iOS判断是否是最新的版本
- iOS 10 判断系统版本正确姿势
- 怎么判断ios 版本
- IOS判断版本
- 怎么判断ios 版本
- 判断 iOS 系统版本
- 判断ios系统版本
- iOS 不同版本 判断
- 判断ios版本
- IOS判断版本
- ios判断系统版本
- 如何判断IOS版本
- IOS判断版本
- ios版本判断
- Java反射
- PopupWindow的最基本使用
- xyssl-0.8或者mbedtls用mingw编译
- Android studio导入OpenCV-android-sdk出现Error:(22, 0) Gradle DSL method not found: 'android()'
- shiro登陆简单 demo
- IOS 10 中版本的判断
- 排序--4. 堆排序
- MySQL添加字段和修改字段的方法
- 一些技术达人的博客收集备份
- 实用API
- HTML第二章上机练习2
- 有序列表
- JAVA文档注释1.1
- 采用SpringBoot+freemaker搭建项目