开发者

How to find out iOS version

Is it possib开发者_运维百科le to read the iOS version (4.2.1, 4.3.3, etc.) running a MonoTouch app? If so, how?


Try UIDevice.CurrentDevice.SystemVersion.


If you only need it for a boolean condition, there is a convenience method:

if (UIDevice.CurrentDevice.CheckSystemVersion (6, 0)) // at least 6.0


In MonoTouch:

To get the Major version use:

UIDevice.CurrentDevice.SystemVersion.Split('.')[0]

For minor version use:

UIDevice.CurrentDevice.SystemVersion.Split('.')[1]


There is a .net System.Version class to convert from string.

var str = "3.5.3858.2";
Version version = Version.TryParse(str,out version) ? version : null;
if(version != null)
{
    // version.Major
    // version.Minor
    // version.Build
} 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜