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

查看:105
本文介绍了如何在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类不提供给我

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

我唯一想到的选择是构建本机扩展并使用IOS函数查询版本。但是我真的不希望构建该扩展。甚至更少,因为显然您需要一台带有XCode的Mac来构建IOS部件,而我却没有Mac。装有OSX的VM可能是我的最后选择。

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天全站免登陆