问题
I'm trying to work with the iOS6 Auto-rotation mess.
I've looked at almost every single SO question relating to it, and no matter what I try, I can't get rotation working how I need it.
The app is using storyboards, and the layout is as follows:
Navigation controller ---> Root view controller ---> Tab view controller ---> View controller ---> Landscape view controller.
The view controller auto-rotates when I rotate the simulator, but when segueing back to the previous view (that is set to portrait), the view becomes landscape, when it should be portrait. If I rotate the simulator back, the view auto-rotates to portrait again, but this should've been done automatically!
I've implemented (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
and it doesn't get called in any view controller I put it in.
I've subclassed the NavigationController to return the topViewController
's shouldAutoRotate
, supportedInterfaceOrientations
and preferredInterfaceOrientationForPresentation
and auto-rotation when rotating the simulator seems to work, but preferredInterfaceOrientationForPresentation
never does its job.
Does anyone have a solution to this?
回答1:
It would appear Apple have removed the ability to push a view in a specific orientation. preferredInterfaceOrientationForPresentation
does get called, but only when popping back or presenting a view controller. I had to present my landscape view rather than push it, and set shouldAutoRotate
= NO.
Refer to: In iOS6, trouble forcing ViewController to certain interfaceOrientation when pushed on stack for more details.
来源:https://stackoverflow.com/questions/16780545/ios6-preferred-interface-orientation-not-working