2014-12-20 8 views
0

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에서 창을 할당하기 때문에라고 생각한다. didFinishLaunching에 코드를 추가하지 않고서도 (isInitialViewController = yes라고 표시하여) 스토리 보드에서 직접 실행하려고하면 자동 회전이 작동합니다. 당신이 볼 수 있듯이, 나는 "viewController"를 rootviewcontroller로로드 할 필요가있다. 내가 뭘 잘못하고있어? 내가 엑스 코드 6.1

Landscape

enter image description here

답변

0

문제를 사용하고

내가 스토리 보드에서보기를로드뿐만 아니라 앱의 위임에 didFinishLaunchingOption에 뷰 컨트롤러를 초기화하는하고 있다는 점이다. 해결책은 스토리 보드에서 초기 뷰로드를 피하는 것입니다.

설정 IsinitialViewController이 하나가 나에게 문제를 해결하는 데 도움이 AppDelegate에

에서 뷰 컨트롤러를 NO와로드합니다. Programmatically set the initial view controller using Storyboards

plist에서는 "메인 스토리 보드 파일 기본 이름"을 비어 있어야합니다.