开发者

pushViewController: - how to display in portrait only mode, when device is in landscape mode?

I have 2 view controllers, root, and detail. The root view controller supports landscape and portrait orientation, so it has the following code:

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
        return (interfaceOrientation == 开发者_如何学GoUIInterfaceOrientationPortrait
        || interfaceOrientation == UIInterfaceOrientationLandscapeLeft
        || interfaceOrientation == UIInterfaceOrientationLandscapeRight
        || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
    }

The above code works perfectly for the root view controller.

If the root view controller is being displayed, and the user rotates the device into landscape mode, the view adjusts accordingly. From this point, if push my detail view controller on to the stack, it loads in landscape mode. But, it shouldn't, because I have it configured to only support portrait mode. I'm using the code below in my detail view controller:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}


In your second view controller, replace your code with ...

return UIInterfaceOrientationIsPortrait( interfaceOrientation );
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜