在我的应用程序中,我检查设备是否运行低于 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 值。
具体来说,RootViewController 在 iOS 4 及更高版本中受支持,但在 iOS 5 及更高版本中是必需的:http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIWindow_Class/UIWindowClassReference/UIWindowClassReference.html
代码在 iOS 6 发布时仍然有效,因为 CheckSystemVersion()
确保您大于传入的值。
关于c# - Monotouch : Setting Window in pre 5. 0 设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11421828/