我想检查用户是否在iOS 5.0以下运行应用程序,并在应用程序中显示一个标签。
我如何以编程方式检测哪个iOS正在用户的设备上运行?
谢谢!
我想检查用户是否在iOS 5.0以下运行应用程序,并在应用程序中显示一个标签。
我如何以编程方式检测哪个iOS正在用户的设备上运行?
谢谢!
当前回答
[[UIDevice currentDevice] systemVersion];
或者像这样检查版本
你可以从这里得到下面的宏。
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(IOS_VERSION_3_2_0))
{
UIImageView *background = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cs_lines_back.png"]] autorelease];
theTableView.backgroundView = background;
}
希望这能有所帮助
其他回答
在MonoTouch:
要获得Major版本,请使用:
UIDevice.CurrentDevice.SystemVersion.Split('.')[0]
对于小版本使用:
UIDevice.CurrentDevice.SystemVersion.Split('.')[1]
要获得分隔主版本和次版本的更具体版本号信息:
NSString* versionString = [UIDevice currentDevice].systemVersion;
NSArray* vN = [versionString componentsSeparatedByString:@"."];
数组vN将以字符串形式包含主版本和次版本,但如果您想进行比较,版本号应该存储为数字(int)。你可以添加这段代码将它们存储在c数组* versionNumbers中:
int versionNumbers[vN.count];
for (int i = 0; i < sizeof(versionNumbers)/sizeof(versionNumbers[0]); i++)
versionNumbers[i] = [[vN objectAtIndex:i] integerValue];
*这里使用的c数组更简洁的语法。
[[[UIDevice currentDevice] systemVersion] floatValue]
[[UIDevice currentDevice] systemVersion]
一个简单的检查iOS版本小于5(所有版本):
if([[[UIDevice currentDevice] systemVersion] integerValue] < 5){
// do something
};