如何从 Flex 移动应用程序 (AIR) 中确定 IOS 版本 [英] How to determine the IOS version from within an Flex mobile app (AIR)

查看:23
本文介绍了如何从 Flex 移动应用程序 (AIR) 中确定 IOS 版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想确定我的 Flex 移动应用程序是否在具有 IOS 7 的 IOS 设备上运行.

I want to determine whether my Flex mobile app is running on a IOS device with IOS 7.

我需要找出因为我想降低应用程序的操作栏,如果它在 IOS 7 上运行,为指标(电池、wifi 等)提供空间.

I need to find out because I want to lower the actionbar of the application if it is run on IOS 7 to provide room for the indicators (battery, wifi, etc.).

根据文档,Flex Capabilities 类没有为我提供 IOS 版本号.

According to documentation the Flex Capabilities class does not provide me with an IOS version number.

我能想到的唯一选择是构建一个Native扩展并使用IOS函数查询版本.但我并不真正期待构建该扩展.更不用说,因为显然您需要一台带有 XCode 的 Mac 来构建 IOS 部分,而我没有 Mac.安装了 OSX 的虚拟机可能是我最后的选择.

The only option I can think of is to build a Native extension and query the version using IOS functions. But I do not really look forward to building that extension. Even less so because apparently you need a Mac with XCode to build the IOS part, and I don't own a Mac. A VM with OSX installed could be my last resort.

也许你知道另一种选择?

Maybe you know another option?

推荐答案

Flex 4.12 实际上引入了一种通过 CSS 解决此问题的方法(4.12 还引入了 OS 和 OS 版本检查,这很棒):

Flex 4.12 actually introduced a way to fix this through CSS (4.12 introduced OS and OS version checks as well, which is awesome):

@media (application-dpi: 160) AND (os-platform:"IOS") AND (min-os-version: 7)
{
    Application {
         osStatusBarHeight: 20;
    }
}

但是为了回答你的问题,这个函数可以完成工作:

But to answer your question, this function does the job:

public static function get iOSVersion():uint {
    var iosVersion:String = Capabilities.os.match( /([0-9]\.?){2,3}/ )[0];
    return Number( iosVersion.substr( 0, iosVersion.indexOf( "." ) ) );
}

我从我的个人 AS3 实用程序库中提取了它.当然,这无法获取 Android 版本号,我不确定它是否适用于 Mac 或 Windows.它将仅返回主要版本号(次要版本通常无关紧要).如果你想改变它,只需在函数中返回 iosVersion 而不是第二行.

I pulled that from my personal AS3 utility library. For sure, this will not work to get the Android version number and I am unsure if it will work for Mac or Windows. It will return the major version number only (minor versions are generally irrelevant). If you want to change that, just return iosVersion in the function instead of the second line.

这篇关于如何从 Flex 移动应用程序 (AIR) 中确定 IOS 版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆