Swift 加载故事板-iOS时的方向问题

Swift 加载故事板-iOS时的方向问题,swift,ios8,uiinterfaceorientation,xcode6.1,ios8.1,Swift,Ios8,Uiinterfaceorientation,Xcode6.1,Ios8.1,我已经在AppDelegate的didFinishLaunching方法中创建了一个视图控制器,并将其分配给窗口的根视图控制器 func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after applicati

我已经在AppDelegate的didFinishLaunching方法中创建了一个视图控制器,并将其分配给窗口的根视图控制器

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.
        window = UIWindow(frame: UIScreen.mainScreen().bounds) // issue with allocating UIWindow
        self.viewController = AKSidePanelController()

        self.viewController!.centerPanel = UINavigationController(rootViewController: UIStoryboard.centerViewController()!)

        window!.rootViewController = self.viewController
        window!.makeKeyAndVisible()
        return true
    }



func shouldAutorotate() -> Bool {
        return true
    }

    func supportedInterfaceOrientations() -> Int {
        return UIInterfaceOrientation.Portrait.rawValue | UIInterfaceOrientation.LandscapeLeft.rawValue | UIInterfaceOrientation.LandscapeRight.rawValue
    }
由于某些原因,“自动旋转”不起作用。我认为问题是因为在didfinishlaunching中分配了窗口。当我试图通过标记isInitialViewController=yes直接从Storyboard启动,而不在didFinishLaunching上添加任何代码时,自动旋转可以工作。如您所见,我需要将viewController加载为rootviewcontroller。我做错了什么

我使用的是Xcode 6.1


问题是,我正在从情节提要加载视图,并在应用程序委托的didFinishLaunchingOption中初始化视图控制器。解决方案是避免从情节提要加载初始视图

将IsinitialViewController设置为否,并从appdelegate加载视图控制器

这个可以帮助我解决这个问题

请注意,您必须在plist中将主情节提要文件基名称设置为空