iPhone - allow landscape orientation on just one viewcontroller

前端 未结 3 1675
终归单人心
终归单人心 2020-12-05 08:20

I have a navigation-based application in which I would like just one of the viewcontrollers to support landscape orientation. For that viewcontroller (vc1), in shouldAutorot

3条回答
  •  粉色の甜心
    2020-12-05 09:17

    I have also situation when I need all view controllers in portait mode, but one of them also can rotate to landscape mode. And this view controller has navigation bar.

    For this purpose I have created second window, in my case it was camera view controller. And when I need to show camera view controller, I show camera window and hide when I need to push another view controller.

    And you also need to add this code to AppDelegate.

    - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
    {   
        if (window == self.cameraWindow)
        {
            return UIInterfaceOrientationMaskAllButUpsideDown;
        }
    
        return UIInterfaceOrientationMaskPortrait;
    }
    

提交回复
热议问题