所以我试图启动一个没有故事板的项目,但我似乎无法弄清楚为什么 UIWindow 没有将自动旋转命令传递给根视图控制器。有了故事板,自动旋转就可以了。如果我以编程方式创建窗口,自动旋转将不起作用。
这是我在应用程序委托中实例化窗口的方式:
window = UIWindow(frame: UIScreen.mainScreen().bounds)
if let window = window {
window.backgroundColor = UIColor.whiteColor()
window.makeKeyAndVisible()
let nc: SignInViewController = UIStoryboard(name: "Main", bundle: nil)
.instantiateViewControllerWithIdentifier("SignInViewController") as SignInViewController
window.rootViewController = nc
}
Thanks!
您使用故事板吗?如果是这样,您的应用程序 didFinishLaunchingWithOptions 方法中可能有旧代码。
尝试删除以下代码行以及与 UIWindow 相关的任何其他代码行:
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] 边界]];
只需要从 AppDelegate.m 文件中删除上面的行即可。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)