My navigation controller's navigation bar won't change the height when rotated to landscape.
see it stays at 44 pixels instead of 34 i think.
What do i do to fix this?
My navigation controller's navigation bar won't change the height when rotated to landscape.
see it stays at 44 pixels instead of 34 i think.
What do i do to fix this?
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.
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);
}
}