I have a simple question: I want to find out the height of a UINavigationBar
in landscape while my device is in portrait. Is this possible and if so, how?
Some background:
UINavigationBar *navBar = [[UINavigationBar alloc] initWithFrame:CGRectZero];
[navBar sizeToFit];
NSLog(@"navBar: %@", NSStringFromCGRect(navBar.frame));
This returns the correct height for the current device orientation, for example 44
. That means that UINavigationBar
's sizeToFit
method must somehow look at the current device orientation. Is there any way to get find out what the height would be in landscape without going to landscape?
Why not grab and set that information in willAnimateRotationToInterfaceOrientation. By overriding this method you should be able to get the info you desire prior to the view being shown.
In other words, don't worry about it until you are actually in the process of changing your orientation.
willAnimateRotationToInterfaceOrientation
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