My app has the following configuration:
- root view controller only supports portrait orientation
- presented view controller supports both portrait and landscape
When presenting VC using default presentation all works as expected - user may rotate the device and presented VC rotates accordingly. After dismissal root VC still shows up in portrait without any unnecessary animations.
However, after switching to custom full screen presentation using UIPresentationController this behavior breaks.
First, the controller being presented completely ignores device rotation. As it turns out, -[UIPresentationController shouldRemovePresentersView] should return YES to make things work. Documentation states this method should be overriden for non-full screen presentations, so it's completely unclear why it affects the rotation in my case.
Second, after dismissing presented VC, presenting VC stays in current device orientation no matter what preferredInterfaceOrientationForPresentation return value is. The only "workaround" I have found so far is using -[UIDevice setOrientation:], but I would like to avoid using private API as much as possible.
First, the controller being presented completely ignores device rotation. As it turns out, -[UIPresentationController shouldRemovePresentersView] should return YES to make things work. Documentation states this method should be overridden for non-full screen presentations, so it's completely unclear why it affects the rotation in my case.
Your presentation controller should override -shouldRemovePresentersView to return YES if your custom presentation completely cover's the presenter's view. When the presenter's view is removed, queries from the window about supported interface orientations are forwarded to the presented view controller.
Second, after dismissing presented VC, presenting VC stays in current device orientation no matter what preferredInterfaceOrientationForPresentation return value is.
I believe this is currently to be expected. The logic for preserving the presenter's orientation is implemented by the private UIPresentationController subclasses used for the built-in presentation styles (e.g. UIModalPresentationStyleFullscreen), not in the UIPresentationController base class. If you need this behavior, you must specify one of the built-in modal presentation styles for your presented view controller. With some exceptions, you can still specify your own transition delegate, and thus can implement your own animations, when using the built-in presentation styles.