How to hide UINavigationController toolbar using storyboard?

I have an iOS storyboard app that has several views that I'm viewing. I have a UINavigationController with the Show Toolbar option selected, which is then populated throughout the view hierarchy.

Say my view stream is 3 views, A, B and C:

View A --(push)--> View B --(push)--> View C 

View A is a regular view controller, with a toolbar button used to press button B. View B is a table controller, so I want to hide the toolbar here. View C is another view, such as View A, with the desired toolbar.

In Xcode / Storyboard, if in the BI view, select “Hides the bottom panel when clicked,” it does just that: the bottom panel is hidden for View B. Similarly, if I select “None” for the “Bottom bar” option, there is no bar to view B . Good.

Here is my problem: no matter what I do, using any option to view B, my toolbar does not return to view C. If I set the View C toolbar as displayed (and uncheck the hide on push checkbox), it will not show as well as if I installed it manually in the "Toolbar".

Any ideas?

+7
source share
2 answers

As Zoltan said, Storyboard does not provide a complete answer.

Setting self.navigationController.toolbarHidden = YES / NO on viewDidLoad or viewWillAppear is functional but ugly (a black rectangle appears instead of the toolbar during the transition animation).

Here's what I did for the View B controller (and vice versa for View C) to simulate the smoothness of the animation of the "hide on push" option in the storyboard:

 - (void)viewWillAppear:(BOOL)animated { [self.navigationController setToolbarHidden:YES animated:YES]; } - (void)viewWillDisappear:(BOOL)animated { [self.navigationController setToolbarHidden:NO animated:YES]; } 
+15
source

I do not think you can do this exclusively in The Storyboard. However, you can simply set it to display always, place buttons on it for each view in which you want it to appear, and you can call self.navigationController.toolbarHidden = YES; when a viewcontroller is loaded in which you do not want the toolbar to display. After that, if another VC appears on which you want the toolbar, simply set the Hidden toolbar to NO.

+2
source

All Articles