我想检查用户是否在iOS 5.0以下运行应用程序,并在应用程序中显示一个标签。
我如何以编程方式检测哪个iOS正在用户的设备上运行?
谢谢!
我想检查用户是否在iOS 5.0以下运行应用程序,并在应用程序中显示一个标签。
我如何以编程方式检测哪个iOS正在用户的设备上运行?
谢谢!
当前回答
[[UIDevice currentDevice] systemVersion]
其他回答
我知道现在回答这个问题已经太迟了。我不确定我的方法是否仍然适用于低iOS版本(< 5.0):
NSString *platform = [UIDevice currentDevice].model;
NSLog(@"[UIDevice currentDevice].model: %@",platform);
NSLog(@"[UIDevice currentDevice].description: %@",[UIDevice currentDevice].description);
NSLog(@"[UIDevice currentDevice].localizedModel: %@",[UIDevice currentDevice].localizedModel);
NSLog(@"[UIDevice currentDevice].name: %@",[UIDevice currentDevice].name);
NSLog(@"[UIDevice currentDevice].systemVersion: %@",[UIDevice currentDevice].systemVersion);
NSLog(@"[UIDevice currentDevice].systemName: %@",[UIDevice currentDevice].systemName);
你可以得到以下结果:
[UIDevice currentDevice].model: iPhone
[UIDevice currentDevice].description: <UIDevice: 0x1cd75c70>
[UIDevice currentDevice].localizedModel: iPhone
[UIDevice currentDevice].name: Someones-iPhone002
[UIDevice currentDevice].systemVersion: 6.1.3
[UIDevice currentDevice].systemName: iPhone OS
[[[UIDevice currentDevice] systemVersion] floatValue]
[[UIDevice currentDevice] systemVersion]
在MonoTouch:
要获得Major版本,请使用:
UIDevice.CurrentDevice.SystemVersion.Split('.')[0]
对于小版本使用:
UIDevice.CurrentDevice.SystemVersion.Split('.')[1]
一个简单的检查iOS版本小于5(所有版本):
if([[[UIDevice currentDevice] systemVersion] integerValue] < 5){
// do something
};