Search code examples
uiviewcontrollerorientationios6

supportedInterfaceOrientations method not working on iOS 6 UIViewController


In iOS 5, my application I used the method to change my orientation:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

In iOS 6 I think I'm supposed to do this, but it does nothing! My app is rotated not the way I want it to be.

- (BOOL) shouldAutorotate
{
    return YES;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscapeRight;
}

Solution

  • It's how I was adding my viewController.

    I replaced this line code:

    [window addSubview:viewController.view];
    

    by this line:

    [window setRootViewController:viewController];