隐藏UINavigationBar只为根UIViewController [英] Hiding the UINavigationBar only for the root UIViewController
问题描述
我使用一个UINavigationController(边注:在一个UITabBar),默认情况下给你一个UINavigationBar在顶部。如果我通过IB隐藏条,该条不仅是为了UIViewController的根,而且对于我推到堆栈的所有控制器。离开我没有(自动)的方式弹出。
I am using a UINavigationController (side note: inside a UITabBar) which by default gives you a UINavigationBar on the top. If I hide the bar through IB, the bar is gone not only for the root UIViewController but also for all the controllers I push onto the stack. Leaving me no (automatic) way to pop back.
那么如何隐藏UINavigtionBar只有根UIViewController。
So how can hide the UINavigtionBar only on the root UIViewController. Switching on/off "navigationBarHidden" temporarily does not work as this looks awkward with the animation.
任何其他想法?
推荐答案
我实际上遇到了这个问题,我如何解决它是与UINavigationCOntroller委托,我基本上有一个UINavigationController子类,并使其自己的委托,然后我实现方法
I actually ran into this problem, how i solved it was with the UINavigationCOntroller delegate, i basically have a UINavigationController subclass and made it its own delegate, then i implemented the method
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
if([viewController isKindOfClass: [SomeClass class]])
[self setNavigationBarHidden: NO];
else
[self setNavigationBarHidden: YES];
}
所以你问哪个类是它,如果它需要有一个navigationBar你显示它,这对我工作很好...希望它帮助
So you ask which class it is and if its one that needs to have a navigationBar you show it, this worked for me pretty well...hope it helps
这篇关于隐藏UINavigationBar只为根UIViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!