Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

franium

macrumors member
Original poster
Nov 18, 2010
34
0
Hi, I have a ViewController that manages a view in which I have a Table View, an ImageView and a Navigation Bar. When I put it in the landscape mode the Navigation Bar doesn't resize to 32, it still remains to 44 I tried first to use the autosizing in IB without success, then I tried to put this code in the ViewController
Code:
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)orientation duration:(NSTimeInterval)duration {
    //[super willAnimateRotationToInterfaceOrientation:orientation duration:duration];
    CGRect frame = self.navigationController.navigationBar.frame;
    if (UIInterfaceOrientationIsPortrait(orientation)) {
         frame.size.height = 44;
    } else {
         frame.size.height = 32;
    }
    self.navigationController.navigationBar.frame = frame;
}
but nothing. How can I solve this issue?
 
What is [self navigationController] pointing to? If your custom view controller is inside a UINavigationController, that should just shrink the navigation bar down for you in landscape for free. It's not working?
 
What is [self navigationController] pointing to? If your custom view controller is inside a UINavigationController, that should just shrink the navigation bar down for you in landscape for free. It's not working?

You are right, I made a mistake... my view isn't in a nav controller... so I link the navbar in the code with an IBOutlet and I've used
Code:
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)orientation duration:(NSTimeInterval)duration {
	//[super willAnimateRotationToInterfaceOrientation:orientation duration:duration];
	CGRect frame = self.navBar.frame;
	if (UIInterfaceOrientationIsPortrait(orientation)) {
		frame.size.height = 44;
	} else {
		frame.size.height = 32;
	}
	self.navBar.frame = frame;
	
}

Now, it works, but the image under the navbar remains still there, so there is a space between the two. The autosizing masks seem not work.
How can I fill that space with the image from the code repositioning the image?
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.