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

来源:互联网 发布:linux为锁添加计数值 编辑:程序博客网 时间:2024/04/30 06:32

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];
      }
    }

 

 

 

 

原创粉丝点击