Search code examples
uiinterfaceorientationios6

Disable Portrait interface in iOS 6


In my UIViewController

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
}

-(BOOL) shouldAutorotate {
    return NO;
}

I should only support Landscape orientation in iOS 6. But it didn't work. It still working auto rotation.

How to fix disable autorotate in iOS 6 ?


Solution

  • Found a solution.

    I am using viewcontroller with UINavigationController. So, I need to change supportedInterfaceOrientations in UINavigationController.

    @interface UINavigationController (autorotate)
    
    @end
    
    @implementation UINavigationController (autorotate)
    
    
    - (NSUInteger)supportedInterfaceOrientations
    {
        return UIInterfaceOrientationMaskLandscape;
    }
    
    -(BOOL) shouldAutorotate {
        return YES;
    }
    
    @end