I'm creating a library which will add a view at the bottom of the application (when my library is integrated in application).
I'm using view controller's view's frame parameter to get the size of the view and calculation my library's view frame according and showing it.
The problem is that when navigation bar is there, my view is going still below the actual view visible. So, i want to know whether current view controller is based on navigation controller or not and whether navigation bar is visible in that view or not. how can I find that?
A user changes the navigation bar's style, or UIBarStyle , by tapping the “Style” button to the left of the main page.
I'm late with the reply, but for other persons who try to do the same thing (like me :D).
This code may solve your problem:
id nav = [UIApplication sharedApplication].keyWindow.rootViewController;
if ([nav isKindOfClass:[UINavigationController class]]) {
UINavigationController *navc = (UINavigationController *) nav;
if(navc.navigationBarHidden) {
NSLog(@"NOOOO NAV BAR");
} else {
NSLog(@"WE HAVE NAV BAR");
}
}
UINavigationBar
inherits from and has all the fine properties and behaviors of UIView
and one of these properties is hidden
.
So for your view, if you can get a handle to your navigation bar, all you need to do is check to see if hidden
is YES
or NO
.
one way to do this would be to have a UINavigationController property or accessor (setter & getter) for your library so whoever makes use of the library can set the navigation controller and/or bar on your library's behalf.
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