iOS Rotate View Controller when Modal View Controller rotates

泄露秘密 提交于 2019-12-09 18:33:46

问题


I have an UIViewController A which opens another modal UIViewController B on UIButton action.

My Question is: When the current modal UIViewController B is open and did rotate - the previous UIViewController A doesn't rotate at all. This implies that when I dismiss UIViewController B - UIViewController A is still in the old state (has still the old interface orientation). Currently I am forcing A to rotate by calling a method in A when B rotates.

Is there another common way to inform other view controllers about rotation? Or what would be the proper way?


回答1:


If you're using iOS 6, then you have (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation. Then, you just have to return the superview's device orientation.

Edit : if you're covering iOS 5, you can also check this.




回答2:


I was having a lot of issues with rotation myself. Have found a solution for all but the root view to first view.

See: Rotation issue from the first view (splash) to first viewController

This is really just notification of a device orientation change. The "libraryTableBorder" is specific to my app. Replace the code inside of the "if" and "else" to what is appropriate for your app.




回答3:


If the presentation style for your modal view is set to current context, it should rotate the view controller A. I had the problem but couldn't figure out why, it appears the settings in interface builder were overriding the ones set in code.

Try that, you can change the transition style obviously



来源:https://stackoverflow.com/questions/13987528/ios-rotate-view-controller-when-modal-view-controller-rotates

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