为了账号安全,请及时绑定邮箱和手机立即绑定

如何以编程方式检测设备运行在哪个IOS版本上?

如何以编程方式检测设备运行在哪个IOS版本上?

撒科打诨 2019-07-11 13:20:10
如何以编程方式检测设备运行在哪个IOS版本上?我想检查用户是否在iOS上运行的应用程序少于5.0,并在应用程序中显示一个标签。如何以编程方式检测用户设备上运行的IOS?谢谢!
查看完整描述

3 回答

?
一只萌萌小番薯

TA贡献1795条经验 获得超7个赞

更新

在iOS 8中,我们可以使用新的isOperatingSystemAtLeastVersion方法上NSProcessInfo

   NSOperatingSystemVersion ios8_0_1 = (NSOperatingSystemVersion){8, 0, 1};
   if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:ios8_0_1]) {
      // iOS 8.0.1 and above logic
   } else {
      // iOS 8.0.0 and below logic
   }

请注意,这将在IOS 7上崩溃,因为API在IOS 8之前并不存在。

if ([NSProcessInfo instancesRespondToSelector:@selector(isOperatingSystemAtLeastVersion:)]) {
  // conditionally check for any version >= iOS 8 using 'isOperatingSystemAtLeastVersion'} else {
  // we're on iOS 7 or below}

原文答案IOS<8

为了完整起见,以下是苹果自己在iOS 7 UI过渡指南,这涉及到检查“基础框架”版本。

if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
   // Load resources for iOS 6.1 or earlier} else {
   // Load resources for iOS 7 or later}


查看完整回答
反对 回复 2019-07-11
?
尚方宝剑之说

TA贡献1788条经验 获得超4个赞

我知道我回答这个问题太迟了。我不确定我的方法是否仍然适用于低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


查看完整回答
反对 回复 2019-07-11
  • 3 回答
  • 0 关注
  • 606 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信