UISplitViewController portrait for landscape rotation disabled in iOS 8 when popover appeared

OK, this is weird.

In iOS 8, if a popover is displayed from the master panel in the UISplitViewController, while in portrait, rotation is disabled. I checked a lot of tests and confirmed that it is.

There is a private method in the UISplitViewController, _shouldPreventAutorotation, which is called upon rotation and checks the presentationController property on the popover content controller. If this returns a value other than zero, rotation is disabled. If you override a property and return zero, rotation is turned on again.

Does anyone know why this behavior was added in iOS 8?

I downloaded a test project demonstrating this behavior here .

+5
source share
1 answer

So, after some investigation and decompilation in Hopper, there is a private method in the UISplitViewController that is called when the device is rotated, which determines whether rotation should be turned off.

If the master panel is visible, the main panel has a child controller for the modal presentation (in this case, popover), and the presented popover presentationController property returns a non-zero value, and then rotation is disabled.

I can override this behavior by overriding the -view-control on the popover controller and return zero. Not sure about any side effects, but it works.

- (UIPresentationController *)presentationController { return nil; } 
+7
source

Source: https://habr.com/ru/post/1213346/


All Articles