Disable rotation for View Controller in Navigation Controller

前端 未结 7 838
闹比i
闹比i 2020-12-19 12:57

First of all, this isn\'t a duplicate. I\'ve looked at all of the questions related to this on SO and none of them work for me. Hopefully it\'s just because I\'m new to iOS

相关标签:
7条回答
  • 2020-12-19 13:37

    You have to check in your root view controller is rotation allowed in current top controller and return YES or NO in supportedInterfaceOrientations method. So it should be like the following code in your root controller (adapt the code to your case):

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

    Then in each view controller add supported interface orientations, for example:

    - (NSUInteger)supportedInterfaceOrientations
    {
        return UIInterfaceOrientationMaskPortrait;
    }
    
    0 讨论(0)
提交回复
热议问题