0
votes

I have a problem with an app I am working on that goes like this:

The app's window has a rootViewController which is set to a custom class (MenuViewController) of UIViewController. This view controller has a rootViewController property of it's own. Whenever set this happens (really short version of the code):

- (void)setRootViewController:(UIViewControlelr *)rootViewController
{
    ...
    _rootViewController = rootViewController;
    if (self.rootViewController) {
        [self addChildViewController:rootViewController];
        [self.view addSubview:rootViewController.view];
    }
    ...
}

Now this MenuViewController can show a modal view controller on top of it's rootViewController.

I do that like this:

[self.rootViewController presentModalViewController:viewController animated:YES completition:nil];

Everything looks to be ok until here. Now on iPad whenever I call [self.presentingViewController dismissViewControllerAnimated:YES completion:nil] from my modal view controller the interface beneath it rotates to the same orientation (that is UIInterfaceOrientationLandscapeLeft) regardless of what the initial orientation was when the view controller was presented.

So to conclude, my view's hierarchy is this:

Window
   |
   - Menu View Controller
      |
      - Root View Controller
          |
          - Modal view controller

Does anyone know how I can fix this? It doesn't happen on the iPhone.

1

1 Answers

1
votes

It sounds to me as though on the iPad your MenuViewController's rootViewController supports multiple interface orientations, whereas on the iPhone it does not. This is speculation, as you have not said anything about this.

If this is the case, and the rootViewController does indeed support multiple interface orientations, the fix would be to override - supportedInterfaceOrientations and return portrait, which seems to be what you are suggesting you would want.