How to determine the IOS version from within an Flex mobile app (AIR)

心不动则不痛 提交于 2020-01-06 08:37:11

问题


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

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.).

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

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?


回答1:


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( "." ) ) );
}

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.



来源:https://stackoverflow.com/questions/22867897/how-to-determine-the-ios-version-from-within-an-flex-mobile-app-air

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!