iOS 6 view controller layout doesn't update after orientation change when covered by a modal view controller

痞子三分冷 提交于 2019-12-07 20:06:46

问题


I have an iPad app which works great for iOS versions earlier than 6.

My root view controller displays a list, and when you click on any item in the list, the root view controller presents a modal view controller to show the item's details.

The problem is, my root view controller has different layouts in landscape and portrait, when there is no modal view controller present, it updates the layout no problem at all when the orientation changes, but when covered by modal view controller, it doesn't update, and this only happens on iOS 6. So when you click on an item, then the modal view controller comes up covering the entire screen, then you rotate the device, and then dismiss the modal view controller, the root view controller is still in old orientation layout, which is really annoying.

I am well aware of the change that in iOS 6 shouldAutorotateToInterfaceOrientation is deprecated and any view controllers covered by a fullscreen modal view controller won't receive rotation events like they did in iOS earlier than 6. I did what was suggested in this thread: iOS 6 Rotation issue - No rotation from Presented Modal View Controller, which is manually pass rotation events from the modal view controller to the view controller behind it, but the view controller behind it still doesn't update its layout. Any solutions?


回答1:


Move all your rotation logic to viewDidLayoutSubviews. It's that simple, you will get the same functionality as before. What will happen is, after you dismiss the modal view controller, the presenting view will be layout, and you can then switch to the appropriate layout for the current orientation.



来源:https://stackoverflow.com/questions/13325484/ios-6-view-controller-layout-doesnt-update-after-orientation-change-when-covere

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