iOS 8:没有故事板,自动旋转无法运行 [英] iOS 8: Autorotation is not working without storyboard

查看:125
本文介绍了iOS 8:没有故事板,自动旋转无法运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我试图启动一个没有Storyboard的项目,我似乎无法弄清楚为什么UIWindow没有将自动旋转命令传递给根视图控制器。通过故事板,自动旋转起作用。如果我以编程方式创建窗口,则自动旋转不起作用。

So I am trying to start a project w/o Storyboards and I can't seem to figure out why the UIWindow is not passing autorotation commands to the root view controller. With storyboards, the autorotation works. If I create the window programmatically, autorotation does not work.

这是我在App Delegate中实例化窗口的方式:

This is how I instantiate the window in the App Delegate:

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
}

谢谢!

推荐答案

标记的答案是降级到XCode 6.0.1 - 我不推荐它。

Marked answer is to downgrade to XCode 6.0.1 - I do not recommend it.

1)如果你不要使用故事板 (本主题的答案!!)

转到 - >项目名称 - >目标 - >项目名称 - >部署信息 - > 主界面 - >将其清空

Go to -> Project Name -> Targets -> Project Name -> Deployment Info -> Main Interface -> Make it Empty

2)如果您使用故事板(不是主要答案)

2) In case you use storyboards (not the main answer)

您的AppDelegate应该看起来像......

your AppDelegate should look like ...

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool 
{
    return true
}

这篇关于iOS 8:没有故事板,自动旋转无法运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆