简体   繁体   English

iOS模拟器iOS版本

[英]iOS Simulator iOS Version

Is there a way to detect what iOS simulator you are running. 有没有一种方法可以检测您正在运行的iOS模拟器。 ie The difference between running 5.1 vs. 6.1. 即运行5.1与6.1之间的差异。

Using [[UIDevice currentDevice] systemVersion] return x86 so i can't determine the difference between the 6.1 simulator and the 7.0 simulator. 使用[[UIDevice currentDevice] systemVersion]返回x86,所以我无法确定6.1仿真器和7.0仿真器之间的差异。

You should take a look at the Availability 您应该看看可用性

The relevant declarations are all in 相关声明都在

Availability.h AvailabilityInternal.h Availability.h AvailabilityInternal.h

#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_6_0
  // Here we go with iOS 6++
#else
  // This is the old way
#endif

[[UIDevice currentDevice] systemVersion] should give you the information you need. [[UIDevice currentDevice] systemVersion]应该为您提供所需的信息。 However, that is not something that should be used for logic. 但是,这不是应该用于逻辑的东西。 It is designed to be a user-presentable string. 它被设计为用户可表示的字符串。

If you want to make logic decisions, you should do it based on capabilities. 如果要做出逻辑决策,则应基于功能来进行决策。 For example, check for the existence of potentially-weak symbols at runtime before using them rather than making decisions based on the system version. 例如,在使用符号之前先在运行时检查它们是否存在,而不要根据系统版本做出决定。

That's easy! 这很容易!

Swift version: 迅捷版:

if #available(iOS 11.0, *) {
} else {
}

Objective-C version: Objective-C版本:

if (@available(iOS 11.0, *)) {
} else {
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM