views:

601

answers:

1

Hi, my application has a tab bar containing nav controllers.

When I rotate, to landscape, I'm switching to a different view by pushing the landscape view onto the nav controller stack as follows:

    - (void) orientationDidChange: (NSNotification *) notification {    
if (self.tabBarController.selectedViewController == self.navigationController) {
 if (self.navigationController.topViewController == self && 
  [[notification name] isEqualToString: kOrientationLandscape]) {
  [self.navigationController pushViewController: landscapeViewController animated: NO];
 } 

 if (self.navigationController.topViewController != self && 
  [[notification name] isEqualToString: kOrientationPortrait]) {
  [self.navigationController popViewControllerAnimated: NO];
 }
}

}

This works fine, but when I rotate back to portrait, the view displays correctly and then 'jumps' up by what I'm guessing is the height of the nav bar. The top of the view is then hidden behind the navigation bar.

If I push another controller on top in the usual manner and then pop back to the portrait view it displays correctly - this only occurs when rotating back from landscape.

Also, it works fine in the simulator, but not on the iPhone. I'm building for 2.0, but it seems to be the same for later versions too.

Any ideas?

Cheers Ash

A: 

Look at my sample-code: link text

strange99