Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I hide the toolbar of a UINavigationController using storyboards?

I have a storyboard iOS app that has a number of views I push through. I have a UINavigationController with the "Shows Toolbar" option selected, which then populates throughout my view hierarchy.

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

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

View A is a normal view controller, with a button on the toolbar used to push View B. View B is a table controller, so I want to hide the toolbar here. View C is another view like View A, with a toolbar required to be shown.

In Xcode/Storyboard, if in View B I select the "Hides bottom bar on push" it does exactly that - the bottom bar is hidden for View B. Similarly if I choose 'None' for the 'Bottom bar' select option, there's no bar for View B. Good.

Here's my problem: No matter what I do, using either option for view B, my toolbar doesn't come back for view C. If I set View C's toolbar as inferred (and uncheck hide on push) it doesn't show, nor if I set it manually to 'Toolbar'.

Any ideas?

like image 795
Freney Avatar asked Aug 07 '12 06:08

Freney


People also ask

How do I remove navigation from storyboard?

Click on the controller that has the top bar navigate to the properties bar on the right hand side of Xcode. There is a drop down labeled Top Bar (as shown above) change this drop down to none.

How do I hide the navigation bar in one screen in Swift?

How To Hide Navigation Bar In Swift. To hide the navigation bar in Swift, you'll need to add code to two methods: viewWillAppear and viewWillDisappear . That's it to hide the navigation bar in your view controller.

How to hide back button navigation?

Touch “Settings” -> “Display” -> “Navigation bar” -> “Full screen gestures”. The navigation bar will be hidden and you will be shown “Gesture demos” to explain how to operate the “Go back”, “Go to Home screen” and “Open Recents” functions.

How to hide navigation back button in iOS?

To hide the back button on navigation bar we'll have to either set the navigation button as nil and then hide it or hide it directly. Let's create a project, add 2 view controller and Embed them in navigation controller.


1 Answers

As @Zoltán said, Storyboard doesn't provide the complete answer.

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

Here's what I did for the View B controller (and the inverse for View C) to mimic the animation smoothness 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];
}
like image 152
Freney Avatar answered Sep 22 '22 07:09

Freney