0

I customized a UITabbarController and give 5 NavigationController to it, such as:

    WXCustomerBar* bar = [[WXCustomerBar alloc]init];   
[bar setViewControllers:[NSArray arrayWithObjects:
                             [[UINavigationController alloc]initWithRootViewController:[[IndexView alloc]init]],  [[UINavigationController alloc]initWithRootViewController:[[SecondView alloc]init]]

In the indexView the tabbar is shown, when I click a button to present another view settingView I want to hide the tabbar. Then when I click the button in settingView, present into the SecondView, I want to display the tabbar.

This is my present method:

-(void)presentToNetViewController:(id)viewController
{
    if (![viewController isKindOfClass:[WXCustomerBar class]]) {
        UINavigationController* navi = [[UINavigationController alloc]initWithRootViewController:viewController];
        [self presentViewController:navi animated:YES completion:nil];
    }else
    {
        [self presentViewController:viewController animated:YES completion:nil];
    }

}

I'm not English, sorry for my odd language.

StarsSky
  • 6,721
  • 6
  • 38
  • 63
kevn liu
  • 33
  • 1
  • 7

1 Answers1

0

UIViewController has a hidesBottomBarWhenPushed property. Set this to YES, and when you do [self presentViewControlller: viewController animated: YES completion: nil], the bar will automatically be hidden until you press the back button.

In addition to this, you are able to tell the UITabBarController itself to hide by doing this:

[self hideTabBar: self.navigationController.tabBarController];

You can look at this answer for more: How to hide uitabbarcontroller

Community
  • 1
  • 1
erdekhayser
  • 6,537
  • 2
  • 37
  • 69