Fir*_*ist 25 objective-c ios ios6
可能重复:
检查iPhone iOS版本
我想在iOS中查看iOS版本.
因为我有一些仅适用于iOS 6的代码.
那我该怎么办?
Fáb*_*ira 49
检查这个GitHub Gist https://gist.github.com/998472
您可以添加代码或将其包含在您的...- Prefix.pch文件中,以便您可以在任何需要的地方使用它.
编辑
我将举例说明如何使用Gist中的代码,以便人们可以检查它是否对他们的案例有用.这也可以在Gist上找到.
/*
* Usage
*/
if (SYSTEM_VERSION_LESS_THAN(@"4.0")) {
...
}
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"3.1.1")) {
...
}
Run Code Online (Sandbox Code Playgroud)
Lor*_*uer 40
试试这个:
更新:
NSArray *vComp = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."];
if ([[vComp objectAtIndex:0] intValue] >= 7) {
// iOS-7 code[current] or greater
} else if ([[vComp objectAtIndex:0] intValue] == 6) {
// iOS-6 code
} else if ([[vComp objectAtIndex:0] intValue] > 2) {
// iOS-3,4,5 code
} else {
// iOS-1,2... code: incompatibility warnings, legacy-handlers, etc..
}
Run Code Online (Sandbox Code Playgroud)
上一个代码:
NSArray *vComp = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."];
if ([[vComp objectAtIndex:0] intValue] == 6) {
// iOS-6 code
} else {
// iOS-5, iOS-4... code
}
Run Code Online (Sandbox Code Playgroud)
要专门检查IOS使用的颠覆
float sysVer = [[[UIDevice currentDevice] systemVersion] floatValue];
if (sysVer > 6.01) {
// iOS-6.01+ code
} else {
// prior iOS versions
}
Run Code Online (Sandbox Code Playgroud)
dsg*_*fin 12
您可以使用以下方式将iOS版本作为字符串获取:
[[UIDevice currentDevice] systemVersion]
Run Code Online (Sandbox Code Playgroud)