Search code examples
iosobjective-cswiftuitabbarcontrolleruitabbar

Hide TabBar when pushed into the navigation stack and bring it back when popped out of the navigation stack


I am trying to do the following.

I have a tab bar controller with 2 tabs in it. Both the tabs are navigation controller with a table view on each of them.

Now when I select one cell of the table in the first tab, I am pushing another tab bar controller, so I would like to hide the tab bar of the parent tabbarcontroller, and when I click the back button on the navigation bar I would like to see the the parent tab bar again, as I am in my parent tab bar view.

I tried hidesbottombarwhenpushed and it hides the parent tab bar controller tab bar but when I click back it doesn't brings it back.


Solution

  • Ok, So finally I got my answer, this is what I am suppose to do.

    self.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:aViewController animated:YES];
    self.hidesBottomBarWhenPushed=NO;
    

    So basically hidesBottomBarWhenPushed = YES, and then push your view controller and then hidesBottomBarWhenPushed = NO; this works like a charm.

    Thanks to eddy and his post here