怎么实现首页隐藏的 UINavigationBar 导航条

隐藏首个导航栏
本文介绍了一种在iOS应用中仅隐藏首个导航控制器的导航栏的方法,以便实现全屏背景图片的效果,并在进入后续视图控制器时正常显示导航栏。

How to hide/disable only the first uinavigationbar?

I've been wandering how to hide / remove / disable only the main or first navigation bar in the navigation controller so that I could put an image as a whole background screen but I couldn't find any solution.

Did try hide the titleview in viewdidLoad of the main navigation controller but didn't work. Tried using navigationBarHidden but it hides the whole navigation bar for the next stack of controller.

So, I'm not sure how to do this. To give you an example, I would like to have something like this app - The Masters Golf Tournament - http://appshopper.com/sports/the-masters-golf-tournament.

If you look at Screen 1, it doesn't have any nav bar at the top but when you touch any options it will push to a new view controller and have the nav bar appear as in Screen 3,4 and 5.

Hope anyone could help me with this.Thanks a lot!

 

In most of my applications I have a custom UIViewController class that I derive all other custom controllers from.  In some of these, I added a method like `navigationBarInitiallyHidden` to the base class that other classes can override.  The default result depends on the nature of the application.

In the delegate of the navigation controller, when a controller is being shown that implements that method, the delegate hides or shows the navigation controller accordingly.  Since I animate the hide or show, I check the current state and do nothing if no change is needed.

You could do something simpler in your delegate method.  If the controller being shown is the root controller, hide the navigation bar, otherwise show it if it is hidden.

    - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
      if ( viewController == rootController ) {
        [navigationController setNavigationBarHidden:YES animated:animated];
      } else if ( [navigationController isNavigationBarHidden] ) {
        [navigationController setNavigationBarHidden:NO animated:animated];
      }
    }

 

 

 

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值