【发布时间】:2014-12-20 07:36:24
【问题描述】:
我在 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)而不在 didFinishLaunching 上添加任何代码时,自动旋转工作。如您所见,我需要将“viewController”加载为 rootviewcontroller。我做错了什么?
我使用的是 Xcode 6.1
【问题讨论】:
标签: swift ios8 uiinterfaceorientation xcode6.1 ios8.1