iOS6 Preferred Interface Orientation Not Working

情到浓时终转凉″ 提交于 2020-01-11 12:51:11

问题


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)preferredInterfaceOrientationForPresentationand 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!