iOS 6 auto rotation issue - supportedInterfaceOrientations return value not respected

拜拜、爱过 提交于 2019-12-03 13:00:07
Mindaugas

I had issue that some ViewControllers in the navigation stack support all the orientations, some only portrait, but UINavigation controller was returning all app supported orientations, this little hack helped me.

@implementation UINavigationController (iOS6OrientationFix)

-(NSUInteger) supportedInterfaceOrientations {
    return [self.topViewController supportedInterfaceOrientations];
}

@end

You also need to add:

- (BOOL)shouldAutorotate {
    return NO;
}

and set the supported rotations for the root view controller in the app plist file to only portrait.

Gleb Tarasov

Category for UINavigationController not working for me. I don't know why. I solve my problem with such category of UIViewController:

@implementation UIViewController (Orientation)

- (BOOL) shouldAutorotate
{
    return YES;
}


- (NSUInteger)supportedInterfaceOrientations
{
    NSUInteger orientations = UIInterfaceOrientationMaskPortrait;

    if ([self isKindOfClass:[PlayerViewController class]])
    {

        orientations |= UIInterfaceOrientationMaskLandscapeLeft;
        orientations |= UIInterfaceOrientationMaskLandscapeRight;

    }

    return orientations;
}

@end
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!