Search code examples
iosobjective-cuiwebviewuiinterfaceorientation

How to use UIInterfaceOrientationPortrait and UIInterfaceOrientationLandscapeLeft


I have a project whose rootViewController is a UINavigationController, and in my project only the view controller loading a full screen UIWebView. I need to change its orientation.

I have finished fixing the issue, but there's some trouble: When a user is in the view controller with the web view in the landscape orientation then clicks the back button, the previous view controller is also in landscape orientation. I want it to be in portrait, however. Any ideas on how to do this?

If you can read Chinese, I found this page, thanks.


Solution

  • implement

    - (NSUInteger)supportedInterfaceOrientations
    {
        return UIInterfaceOrientationMaskPortrait;
    }
    

    for whatever viewcontroller you require to stay in portrait.