How to force a screen orientation in specific view controllers?

前端 未结 4 734
猫巷女王i
猫巷女王i 2020-12-16 14:06

My application is pretty simple: it starts up with a view controller that holds a table view (in grouped view layout) with a few options. When the user taps on one of the op

4条回答
  •  粉色の甜心
    2020-12-16 14:38

    Like someone on the open radar suggested, a workaround is to disable "back" button while in non-portrait:

    - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
        // don't let user press "back" button in landscape - otherwise previous view and the rest of the application
        // will also be in landscape which we did not feel like testing yet
        self.navigationController.navigationBarHidden = (UIInterfaceOrientationPortrait != self.interfaceOrientation);
    }
    

提交回复
热议问题