如何查看iOS版本是iOS 6?
可能重复:
检查iPhone的iOS版本
我想在iOS中检查iOS版本。
因为我只有一些iOS 6的代码。
那我该怎么办?
检查这个GitHub Gist https://gist.github.com/998472
您可以添加代码或将其包含在…- Prefix.pch文件中,以便您可以随时随地使用它。
编辑
我将留下一个例子,说明如何使用Gist的代码,以便人们可以检查它是否适用于他们的情况。 这也可以在Gist上find。
/* * Usage */ if (SYSTEM_VERSION_LESS_THAN(@"4.0")) { ... } if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"3.1.1")) { ... }
尝试这个:
更新:
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.. }
前面的代码:
NSArray *vComp = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."]; if ([[vComp objectAtIndex:0] intValue] == 6) { // iOS-6 code } else { // iOS-5, iOS-4... code }
要专门检查一下IOS的使用颠覆
float sysVer = [[[UIDevice currentDevice] systemVersion] floatValue]; if (sysVer > 6.01) { // iOS-6.01+ code } else { // prior iOS versions }
您可以使用以下命令将iOS版本作为string获取:
[[UIDevice currentDevice] systemVersion]