iOS6: supportedInterfaceOrientations not working (is invoked but the interface still rotates)

前端 未结 15 641
野趣味
野趣味 2020-11-29 04:09

In my app I have multiple views, some views need to support both portrait and landscape, while other views need to support portrait only. Thus, in the project summary, I ha

15条回答
  •  执笔经年
    2020-11-29 04:27

    Basically as someone stated above, but in more detail:

    1. Create a new file that is a subclass of UINavigationController
    2. Go to your storyboard and then click on the Navigation Controller, set its class to the one that you just created
    3. In this class(.m file) add the following code so it will remain in portrait mode:

      (BOOL)shouldAutorotate
      {
        return NO;
      } 
      
      (NSUInteger)supportedInterfaceOrientations
      {
       return UIInterfaceOrientationMaskPortrait;
      }
      

    This worked for me

提交回复
热议问题