views:

98

answers:

2

I've created a custom UIViewController that mimics the UISplitViewController. It manages two child view controllers that get displayed in the left & right body area while in landscape and hides the left to show in a popover when in portrait. It works fine, using the didRotateFromInterfaceOrientation: and willRotateToInterfaceOrientation: messages to reset the location and sizing of the child views. All the views and child controllers are loaded from a nib. This custom view controller is shown inside a UINavigationController.

The trouble arises after one of the child view controllers uses presentModalViewController. If the device was rotated after the views were initialized (but before the modal controller is shown), after the modal dialog is dismissed, the left and/or body views will be re-rendered in a different rotation than they were before the modal dialog was changed.

I'm wondering if folks have had a similar problem, and what the solution is. I'm sure sample code would be helpful, but it'll take a bunch of work to distill it into a runnable sample.

A: 

Yes, I had the same problem but could not find a solution. I was thinking of couple of things: When orientation changes present each of the child view controllers modally with no animation and dismiss immediately. This works, but I had problems showing 2 viewcontrollers one after another. Also when a view controller is presented modally some additonal calls to viewWillAppear etc are made which might make the application unpredictable.

Another idea was to add to a tabviewcontroller and present it the same way. But this did not work. So I resorted to workaround of not presenting any viewcontroller modal to the child viewcontroller. Also self.interfaceorientation cannot be trusted for that reason.

S. P
A: 

When I saw this same behavior in my split view app, I noticed that it only happens when I'm holding the device in "left home button" landscape. I had set my initial interface orientation to "right home button" but was allowing either left or right home button landscape orientations (no portrait orientation for this app). My solution was to no longer support left home button landscape orientation and now all post-modal subviews display reliably.

ScottS