Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/95.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Monotouch:在5.0之前的设备中设置窗口_C#_Ios_Mono_Xamarin.ios - Fatal编程技术网

C# Monotouch:在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();

在我的应用程序中,我检查设备是否运行低于iOS 5.0,并将主视图添加到如下窗口:

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()
确保您大于传入的值