是否可能读取运行MonoTouch应用程序的iOS版本(4.2.1、4.3.3等)?如果可以,如何实现?
试试使用 UIDevice.CurrentDevice.SystemVersion
。
如果你只需要用于布尔条件,有一个便捷的方法:
if (UIDevice.CurrentDevice.CheckSystemVersion (6, 0)) // at least 6.0
UIDevice.CurrentDevice.SystemVersion.Split('.')[0]
使用小版本号:
UIDevice.CurrentDevice.SystemVersion.Split('.')[1]
有一个 .net 的 System.Version 类可以将字符串转换。
var str = "3.5.3858.2";
Version version = Version.TryParse(str,out version) ? version : null;
if(version != null)
{
// version.Major
// version.Minor
// version.Build
}
new Version(UIDevice.CurrentDevice.SystemVersion)
来获取 System.Version 的实例。 - Felix AlcalaCheckSystemVersion
。 - Dan Abramov