开发者

iPad interfaceOrientation not read when new view controller is pushed

开发者 https://www.devze.com 2023-01-20 04:56 出处:网络
I am writing an iPad application which uses a menu from a popover to change the view displayed. I have a root view controller which is always present and changes its content view to the sub view contr

I am writing an iPad application which uses a menu from a popover to change the view displayed. I have a root view controller which is always present and changes its content view to the sub view controllers, e.g Home, News, etc...

Now here's the problem: Let's say I'm on the Home controller in portrait mode, then go to the news controller, then rotate to landscape, the root controller rotates fine and so does the news controller it contains. But when i go back to the home controller, it is still in portrait mode. The view is rotated to landscape orientation but its size is still in portrait so the width is still (768 px wide). The root view controller which presents all subcontrollers rotates correctly the content view does not rotate if it is not present

How do I fix this? I'm thinking something I could set in viewWillAppear but trying to set the interfaceOrientation forcefully does not work as it is readonly.

开发者_运维技巧

Thanks


Try [self setAutoResizesSubviews:YES] in the viewDidLoad: method on your root view controller.

Edit: I assumed that you have it so, but in Interface Builder, are your views set to autoresize? When you test rotation by hitting the little arrow in the upper right hand corner of the simulated interface, does everything resize correctly? Also, it may be similar to problems people have had with tab bar views auto-rotating. Have you seen this question or this one?

Lastly, if none of that works, you could override layoutSubviews in the root view controller and resize the contained views manually.


Nothing seems to work. When device is in landscape mode and all of the content is in landscape mode as well, having the current navigation controller pop the current view and push a new view ALWAYS put the new view and the entire screen content in portrait.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号