HidesBottomBarWhenPushed, but when pressed

I have a problem with something that seems very simple. My application has a view hierarchy consisting of a UITabBarController containing UINavigationControllers. When I move from the root to the second level I set hidesBottomBarWhenPushed to true so that the tab bar is hidden.

On my firstLevelController:

[secondLevelController setHidesBottomBarWhenPushed:YES]; [self.navigationController pushViewController:secondLevelController animated:YES]; 

After that, when I click on the third level, I again bring up the tab bar, running in the second LevelController:

 [self setHidesBottomBarWhenPushed:NO]; [thirdLevelController setHidesBottomBarWhenPushed:NO]; [self.navigationController pushViewController:thirdLevelController animated:YES]; 

(I know I didn't like it either [self setHidesBottomBarWhenPushed:NO] , but it didn't work otherwise ...)

So here is the problem: when I click the back button on the third level and the second view appears, I need to hide the panel again, but I could not find a way to do this.

Any help is appreciated

+3
source share
5 answers

This is what works for me.

 [self setHidesBottomBarWhenPushed:NO]; [thirdLevelController setHidesBottomBarWhenPushed:NO]; [self.navigationController pushViewController:thirdLevelController animated:YES]; [self setHidesBottomBarWhenPushed:YES]; 

Third level The controller shows the tab, and the second Level Controller does not show tabs when you pop out the third Level Controller.

+12
source

On your second controller, do:

 - (BOOL) hidesBottomBarWhenPushed { return ([self.navigationController.viewControllers lastObject] == self); } 

Thus, the tab will always be hidden if you are on the second controller, and it will appear on other view controllers

+5
source

You can save the bool value to see if you are coming from a popViewController and in viewDidAppear you may find that it hides your tab bar again.

 - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; if(backFromThirdView) [self setHidesBottomBarWhenPushed:YES]; else [self setHidesBottomBarWhenPushed:YES]; 

}

0
source

I had the same problem. I always tried to hide the tab when selecting a row and disable hiding after returning to the list (tabular view inside the navigation controller) so that the user can select the menu again. I installed tabbarcontroller hidden inside the method

 -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 

but when I hid it inside this method, Tabbar was still hiding when it returned to my list. Now I hide the Tabbarcontroller inside the init method of the specific view manager, maybe this works for someone else too:

 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{ self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } [self setHidesBottomBarWhenPushed:YES]; return self; } 

Now, when I select a list item, and this view manager will be presented, the timebar is hidden, after returning to the list it appears again.

0
source

You can try this

You declare in the second LevelController

 static BOOL bottomBarShouldHide = YES; 

In viewDidLoad

 if (bottomBarShouldHide) { [secondLevelController setHidesBottomBarWhenPushed:YES]; bottomBarShouldHide = NO; } else { [secondLevelController setHidesBottomBarWhenPushed:NO]; bottomBarShouldHide = YES; } 

Hope this helps you.

-1
source

All Articles