2

I've got an app with the following structure:

UIWindow
   -- GlobalNavigationController.view (subclasses UIViewController)
      -- UIView
      -- UINavigationController.view

GlobalNavigationController forwards all rotation and lifecycle events (viewWillAppear, willRotateToInterfaceOrientation, etc) to the navigation controller.

Everything works really well, until you:

  1. Open a modal dialog
  2. Rotate into landscape (or to another orientation)
  3. Close the dialog.

At this point, it seems that the underlying views in UINavigationController were not informed about some of the rotation events.

You get views like this:

Screenshot after rotation

Any idea? Thanks

Scott Montgomerie
  • 1,780
  • 1
  • 16
  • 17

3 Answers3

0

In your modal view controller, try setting up the following:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
    [self.parentViewController didRotateFromInterfaceOrientation:fromInterfaceOrientation];
}

This sends the message that the view rotated to its parent, which is the view that presented the modal window

justin
  • 5,811
  • 3
  • 29
  • 32
0

I encountered a similar issue with an app I was working on. It turns out, my problem was I did not correctly specify how my control (e.g. top tool bar) were to grow and strech.

If the issue is not a code issue, take a look at IB and see if you have defined autogrow, etc.

Ali
  • 2,163
  • 1
  • 16
  • 18
0

It turned out to be a problem where the navigation controller did not have a parentViewController property set. Love the undocumented gotchas...

The simple solution was putting this after the navigation controller initialization:

[_navigationController setValue:self forKey:@"_parentViewController"];

Props to PrimaryFeather for the idea: Modal View Controller Won't Start in Landscape Mode

Community
  • 1
  • 1
Scott Montgomerie
  • 1,780
  • 1
  • 16
  • 17