开发者

Popping view from UINavigationController changes device orientation

I have an issue issue with the UINavigationController on the iPad. When the app is started in landscape orientation, popping the top view controller from the navigation controller causes the device orientation to turn into portrait and the view displayed slides down when the view that becomes visible and adjusts to portrait orientation. It makes no difference if I 开发者_开发知识库initiate the call or if it's done automatically by the back button.

When the app is started in portrait mode and device is turned into landscape later I don't see the same behavior and everything works fine.

Any pointers to where and what to look for to find the cause or workaround suggestions to prevent this from happening are welcome.

Thank you, Oz


One of the view controllers in your UINavigationController's view hierarchy is not overriding the shouldAutorotateToInterfaceOrientation: method, which by default only returns YES for UIInterfaceOrientationPortrait – so, when that particular view controller comes to the front, it auto-rotates to an orientation it supports.

You can fix this by finding the offending view controller and adding the code below:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Overriden to allow any orientation.
    return YES;
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜