C# Monotouch:在5.0之前的设备中设置窗口
在我的应用程序中,我检查设备是否运行低于iOS 5.0,并将主视图添加到如下窗口:C# Monotouch:在5.0之前的设备中设置窗口,c#,ios,mono,xamarin.ios,C#,Ios,Mono,Xamarin.ios,在我的应用程序中,我检查设备是否运行低于iOS 5.0,并将主视图添加到如下窗口: if (UIDevice.CurrentDevice.CheckSystemVersion(5, 0)) window.RootViewController = tabBarController; else window.AddSubview(tabBarController.View); // make the window visible window.MakeKeyAndVisible();
if (UIDevice.CurrentDevice.CheckSystemVersion(5, 0))
window.RootViewController = tabBarController;
else
window.AddSubview(tabBarController.View);
// make the window visible
window.MakeKeyAndVisible();
我的问题是:这真的需要吗?我可以一直这样做吗:
window.RootViewController = tabBarController;
后续问题:当iOS(超过5.x)理论上面世时,这会起作用吗?如果你没有iOS 5.0的上述检查,你的应用程序将在旧版操作系统上崩溃。较旧的操作系统在UIWindow上没有RootViewController值 具体而言,iOS 4及更高版本支持RootViewController,但iOS 5及更高版本需要: 当iOS 6出现时,代码仍然有效,因为
CheckSystemVersion()
确保您大于传入的值