How to maintain presenting view controller's orientation when dismissing modal view controller?

前端 未结 9 2092
礼貌的吻别
礼貌的吻别 2020-11-30 03:57

I have this app I am working on and I need ALL my view controllers but one to be in portrait. The single one view controller that is special I need it to be able to rotate t

9条回答
  •  情深已故
    2020-11-30 04:36

    This is actually easier and can be done without any additional properties (here's an example with AVPlayerViewController):

    - (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
    {
        if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
            if ([self.window.rootViewController.presentedViewController isKindOfClass: [AVPlayerViewController class]])
                return self.window.rootViewController.presentedViewController.isBeingDismissed ? 
                UIInterfaceOrientationMaskPortrait : UIInterfaceOrientationMaskAll;
            else
                return UIInterfaceOrientationMaskPortrait;
        } else {
            return UIInterfaceOrientationMaskAll;
        }
    }
    

提交回复
热议问题