Is it possible to read the iOS version (4.2.1, 4.3.3, etc.) running a MonoTouch app? If so, how?
4 Answers
Try UIDevice.CurrentDevice.SystemVersion
.
-
-
-
You can use ´new Version(UIDevice.CurrentDevice.SystemVersion)´ to get an instance of System.Version Feb 6, 2013 at 13:38
-
If you only need it for a boolean condition, there is a convenience method:
if (UIDevice.CurrentDevice.CheckSystemVersion (6, 0)) // at least 6.0
-
If I am not wrong, the above can check versions like 6.0, 6.1 but not "9.3.1" and "9.3.2". Jun 28, 2016 at 10:06
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
}