有没有办法检测你正在运行的 iOS 模拟器。即运行 5.1 与 6.1 的区别。
使用 [[UIDevice currentDevice] systemVersion] return x86 所以我无法确定 6.1 模拟器和 7.0 模拟器之间的区别。
有没有办法检测你正在运行的 iOS 模拟器。即运行 5.1 与 6.1 的区别。
使用 [[UIDevice currentDevice] systemVersion] return x86 所以我无法确定 6.1 模拟器和 7.0 模拟器之间的区别。
你应该看看可用性
相关声明都在
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
这很容易!
斯威夫特版本:
if #available(iOS 11.0, *) {
} else {
}
Objective-C 版本:
if (@available(iOS 11.0, *)) {
} else {
}
[[UIDevice currentDevice] systemVersion] should give you the information you need. 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.