3

My navigation controller's navigation bar won't change the height when rotated to landscape. alt text

see it stays at 44 pixels instead of 34 i think.

What do i do to fix this?

Daniel Node.js
  • 6,734
  • 9
  • 35
  • 57

2 Answers2

5

You have to add your navigation controller directly as a subview to your window, otherwise this doesn't work automatically. (It is not necessary to change the frame of your navigation bar manually.)

The -[application:didFinishLaunchingWithOptions:] method of your AppDelegate should contain something like

[window addSubview:self.yourNavController.view];


To get an example where this works automatically, you can also create a new navigation-based app in XCode and add an implementation for the shouldAutorotateToInterfaceOrientation: method of the RootViewController that always returns YES.

mrueg
  • 8,185
  • 4
  • 44
  • 66
-1

During the autoRotation method of your class, change the frame of your navBar like this:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
    if((self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (self.interfaceOrientation == UIInterfaceOrientationLandscapeRight))
    {
         self.navigationController.navigationBar.frame = CGRectMake(0,0,480,32);
    }
    else if((self.interfaceOrientation == UIInterfaceOrientationPortrait) || (self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown))
    {
         self.navigationController.navigationBar.frame = CGRectMake(0,0,320,44);
    }
    else
    {
         assert(false);
    }
}
Bittu
  • 676
  • 2
  • 8
  • 22