【问题标题】:How do I check if a device is running iOS 6? [duplicate]如何检查设备是否运行 iOS 6? [复制]
【发布时间】:2012-10-03 03:16:35
【问题描述】:

可能重复:
How can we programmatically detect which iOS version is device running on?

如何检查设备是否运行 iOS 6?我需要检查操作系统是否为 iOS 6,以便更改我的 youtube 视频网址,因为 Apple 发布了关于如何在 iOS6 中处理它们的发布说明

从 iOS 6 开始,嵌入的 YouTube URL 格式为 http://www.youtube.com/watch?v=oHg5SJYRHA0 将不再起作用。这些 URL 用于在 YouTube 网站上观看视频,而不是用于嵌入 在网页中。相反,应该使用的格式在 https://developers.google.com/youtube/player_parameters.

我正在考虑一个 if else 语句来处理这个问题。

感谢您的帮助

【问题讨论】:

标签: iphone objective-c ios ios6


【解决方案1】:

在比较浮点参数之前,您应该将 6.0 放入浮点变量中,以便 LHS 和 RHS 应该相同才能进行比较:

float currentVersion = 6.0;

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= currentVersion)
{
    NSLog(@"Running in IOS-6");
}

【讨论】:

【解决方案2】:
NSString *versionString = [[UIDevice currentDevice] systemVersion]; // iOS version as string
int versionStringInt = [ver intValue]; // iOS version as int
float versionStringFloat = [ver floatValue]; // iOS version as float

【讨论】:

    【解决方案3】:

    试试下面

     float deviceVersion   = [[[UIDevice currentDevice] systemVersion] floatValue];
     NSLog(@"My Device version is :%f ",deviceVersion);
    

    希望对你有帮助。

    【讨论】:

    • 您可能想做类似if (deviceVersion >= 6.0) 之类的事情,因为一旦 6.1 推出,该代码就会失败并再次假定它在 5.x 上。
    • 检查明确的版本号几乎总是错误的。而是检查功能。
    • 嘿@Shayne 你是对的,但在这里我只是表明我也不赞成上面这就是为什么我要修改我的答案。
    • @Roger 那么您如何检查功能呢?例如使用IOS6新的UIActivityViewController进行社交分享功能,不支持时手动调用TWTweetComposeViewController和邮件分享?
    猜你喜欢
    • 2012-09-15
    • 2011-12-11
    • 1970-01-01
    • 1970-01-01
    • 2019-01-04
    • 1970-01-01
    • 2011-05-21
    • 2011-09-08
    • 1970-01-01
    相关资源
    最近更新 更多