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
- (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?
1 Swipe down the screen to access your Quick Settings and tap on Auto Rotate, Portrait or Landscape to change your screen rotation settings.
The Basic Solutions If the screen rotation is already on try turning it off and then on again. To check this setting, you can swipe down from the top of the display. If it's not there, try going to Settings > Display > Screen rotation.
Select the content that you want on a landscape page. Go to Layout, and open the Page Setup dialog box. Select Landscape, and in the Apply to box, choose Selected text.
I made a mistake, there isn't a navigationController, so I linked the navigation bar in IB with the outlet navBar in the code and I've used
- (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;
}
It works now, I've only a problem with the image view
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With