views:

320

answers:

3

I have two UIViewControllers, "A" and "B", where "A" overrides the shouldAutorotateToInterfaceOrientation to return YES for UIInterfaceOrientationPortrait, and "B" returns YES for all orientations. In my example "A" is the root navigation view controller, and I then use pushViewController for "B". After that I rotate the device into landscape, which successfully autorotates "B", then I pop "B" (back button or via popViewController) to return to "A".

When targetting iPhone OS 3.1.3, "A" returns to the portrait orientation as expected. When targetting iPhone OS 3.2, I have two side-effects:

  1. "A" is displayed in landscape.
  2. The navigation bar does not update even though "A" is now displayed. The navigation bar still shows the items for "B". Only after trying to go back/pop one more time will the navigation bar animate to show the items for "A". If I instead attempt to push "B" again and go back, I have to pop twice before the navigation bar animates to show the items for "A". During these "intermediate pops" the view for "A" remains displayed.

While researching this issue, I have seen other answers suggesting performing the rotation manually ([UIDevice setOrientation] or via a tranformation), however this does not help understand what the problem is, especially why it behaves differently between the two OS's.

So my question is: must all of my UIViewControllers on the UINavigationController stack support exactly the same orientations going forward? And if not, then is there something that I need to do to make it behave as it did for OS 3.1.3?

A: 

Is this behavior happening on both the device and the simulator? I had a similar problem that only happened on the simulator due to simulator bugs.

MrHen
I first saw the problem on my coworker's iPad. After that I fired up the 3.2 simulator and was able to reproduce the issue. Seems to work fine on both the 3.1 simulator and iPhone 3G.
JoeGaggler
A: 

I have the same problem and I found the answer on this link: http://stackoverflow.com/questions/2694613/uinavigationcontroller-navigation-stack-problems-in-landscape-mode one of my view controllers was not return YES on shouldAutorotateToInterfaceOrientation.

Tùng Đỗ
Thanks for you answer. In my case both "A" and "B" are returning values for shouldAutorotateToInterfaceOrientation, with "A" only returning YES for portrait, since that is the only one it supports. Do I need to return YES for a view controller that I am not aware of (neither A nor B)?
JoeGaggler
A: 

It would appear that the newer OS's require all UIViewControllers in the UINavigationController stack to support the same set of orientations.

JoeGaggler