美文网首页
iOS10中系统版本的判断

iOS10中系统版本的判断

作者: 平__淡 | 来源:发表于2016-09-21 17:02 被阅读0次

在iOS10中,当需要判断系统版本号的时候,不能再用以下这种方法了:

#define isiOS10 ([[[[UIDevice currentDevice] systemVersion] substringToIndex:1] intValue]>=10)

这是为什么呢? 因为在iOS10中,substringToIndex:1 iOS 10会被检测成iOS 1,所以此结果永远都是返回NO。

你应该使用下面这些方法:

#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)

Swift中可以这样写:

if #ava

if #available(iOS 10.0, *) {

//iOS 10以上系统

} else {

//iOS 10之前的系统

}

相关文章

  • iOS10中系统版本的判断

    在iOS10中,当需要判断系统版本号的时候,不能再用以下这种方法了: #define isiOS10 ([[[[U...

  • iOS10和Xcode8适配整理

    *摘抄于网络各路大神 — — * 一、iOS10 适配问题 1. 系统判断版本方法 2. UserNotific...

  • 苹果ios怎么降级?

    IOS10新出以后,很多苹果用户为了体验苹果设备iOS10新系统,纷纷将手机更新到了iOS10的系统版本。但是新出...

  • WKWebView刷新机制小探

    create at 2016.11.07 20:58 背景 iOS的一个坑。在线上的版本中,iOS10系统中,ap...

  • iOS10 适配总结

    先整理一下iOS10适配内容 1、iOS 10 版本适配问题 1.系统判断方法失效2.隐私数据访问问题3.UICo...

  • 视频app抖音-产品体验报告

    一、体验环境 设备:iPhone6 操作系统:IOS10 体验版本:1.5.0 版本更新时间:2017.7.10 ...

  • 系统版本的判断

    1.系统版本的判断 1). if([[[UIDevicecurrentDevice] systemVersion]...

  • 英语听说测试系统IOS访问方案

    先决条件: IOS系统版本>=11(可能IOS10也行) IpadoriPhone皆可 仅可以使用系统自带Safa...

  • 录音宝产品体验报告

    产品概述 1.体验环境 设备:iphone6s 系统版本:ios10 APP版本:3.0.1161 体验时间:20...

  • WKWebView刷新机制小探

    背景 iOS的一个坑。在线上的版本中,iOS10系统中,app内使用WKWebView当作一个普通的子View来展...

网友评论

      本文标题:iOS10中系统版本的判断

      本文链接:https://www.haomeiwen.com/subject/uoqaettx.html