0

I have created a view controller in didFinishLaunching method of AppDelegate and assigning it to window's root view controller.

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
    }

for some reasons, auto rotation is not working. i think the problem is because of allocating window in didfinishlaunching. When i try to launch directly from storyboard(by marking isInitialViewController = yes) without adding any code on didFinishLaunching, autorotation works. As you can see, i need to load "viewController" as rootviewcontroller. What i am doing wrong?

I am using Xcode 6.1

Landscape

enter image description here

iPhone Guy
  • 1,285
  • 3
  • 23
  • 34

1 Answers1

0

The problem is that i am loading View from storyboard as well as initialising view controller in didFinishLaunchingOption in App delegate. the solution is to avoid loading initial View from storyboard.

Set IsinitialViewController to no and load the view controller from appdelegate

This one helps me to fix the issue. Programmatically set the initial view controller using Storyboards

Note that you have to make "Main storyboard file base name" as empty in plist.

Community
  • 1
  • 1
iPhone Guy
  • 1,285
  • 3
  • 23
  • 34