Provide an easy way to temporarily lock rotation

Originator:steipete
Number:rdar://12340940 Date Originated:21-Sep-2012 12:26 AM
Status:Open Resolved:
Product:iOS Product Version:6.0
Classification:Enhancement Reproducible:-
 
21-Sep-2012 12:26 AM Peter Steinberger:
With the new autorotation-changes, it has become almost impossible for a view controller to reliably lock rotation. 

In my case, I do provide a component for other apps (http://pspdfkit.com) - and at some point need to lock rotation (e.g. during annotation drawing). Previously to iOS6, this was done via shouldAutorotateToInterfaceOrientation and returning NO in some cases.

In iOS6, this is no longer possible, and I can't use supportedInterfaceOrientations/shouldAutorotate because my controller is supposed to be inside a UINavigationController (and that one might also be a child-controller of another controller). So without full control of the app, there's no reasonable way to lock the orientation. 

Currently I do some swizzling so that at least on UINavigationController the topViewController is queried for supportedInterfaceOrientations - but that's a ugly, incomplete fix.

What I would need is a global rotation lock like the one that exists in UIWindow (https://github.com/steipete/iOS-Runtime-Headers/blob/master/Frameworks/UIKit.framework/UIWindow.h#L209)

I understand that this can also be dangerous (esp. when someone forgets to call the corresponding endDisablingInterfaceAutorotation) - but it would a lot more elegant than anything I can come up with right now.


Of course in a perfect world, one would never need to block autorotation, however there are a lot of cases where this is useful and needed. Even Apple uses this to e.g. finish the pageCurl animation in UIPageViewController. 

And don't get me wrong - I totally understand WHY you changed the rotation philosophy - and it really doesn't make sense for a controller to just show in portrait in the new child/parent view controller world; just there's still this other edge case that now got impossibly hard to achieve.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!