7

I want to hide the bottom toolbar on a certain screen in my application, and IB seems to have an option for that which seems to preview as working correctly, but when I build and test the application the bottom toolbar is still there.

I know that I can use [self.navigationController setToolbarHidden:YES]; but my question is not how to do it using code, but how to get this to work through Interface Builder.

enter image description here

Here is a screenshot of what I am talking about. See on the right how I have selected Bottom Bar: None - this removes the bottom bar as previewed to the left. If I set it to inferred (instead of None) the bottom bar shows in the IB preview.

How do I get this to work correctly?

Baub
  • 5,004
  • 14
  • 56
  • 99

3 Answers3

5

You can't set this in Interface Builder. If you notice the header of the section in IB where you can turn on/off these different bars, it says "simulated". These options are only there to help you visualize your UI in IB while designing it. They have absolutely no influence on the running app.

Ole Begemann
  • 135,006
  • 31
  • 278
  • 256
  • 'doh! So should I just use the code in the `viewWillAppear` and `viewWillDisapper` methods to hide it and bring it back respectively? – Baub Nov 07 '11 at 17:46
  • 2
    Yes, that's what you should do. – Ole Begemann Nov 07 '11 at 17:51
  • 1
    Also note that there is an option called "Hides Bottom Bar on Push" which will do what you are asking for in case the ViewController in question is pushed onto a navigation stack. – Till Nov 07 '11 at 18:02
  • Is there any way to animate this? – Baub Nov 07 '11 at 18:03
  • @James, my suggestion does animate the hide process, yes. – Till Nov 07 '11 at 18:05
  • @Till I see a problem with this: When I get pushed back to that initial view controller that DOES have the toolbar, it doesn't have the toolbar when I get back to it. – Baub Nov 07 '11 at 18:07
  • @James just have a peek at http://stackoverflow.com/questions/5072382/show-uitabbar-when-uiviewcontroller-pushed – Till Nov 07 '11 at 18:12
  • It is not right what @OleBegemann says. Is not simulated. It works perfectly, at least in XCode Version 4.6.3 – enagra Jul 12 '13 at 16:52
4

I couldn't do it in storyboard when you just want to hide toolbar in one view controller. If you want to hide it for all, you need to go to the navigation controller, and set the values in the storyboard. But this makes all of your view controllers to hide the toolbars. If you want to hide it for one view controller use this in that view controller:

-(void) viewWillAppear:(BOOL)animated
{
    [self.navigationController.toolbar setHidden: YES];
}

-(void) viewWillDisappear:(BOOL)animated
{
    [self.navigationController.toolbar setHidden: NO];
}
coolcool1994
  • 3,704
  • 4
  • 39
  • 43
3

Enable "Hides Bottom Bar on Push" within the IB in case your ViewController is pushed onto a UINavigationController stack.

This should exactly do what you are asking for. As a bonus, the hiding and showing will be nicely animated by the system.

Till
  • 27,559
  • 13
  • 88
  • 122
  • 3
    I see a problem with this: When I get pushed back to that initial view controller that DOES have the toolbar, it doesn't have the toolbar when I get back to it. – Baub Nov 07 '11 at 18:11
  • @James That can be solved by setting `UINavigationController`'s _Shows Toolbar_ option. – Rudolf Adamkovič Jan 09 '13 at 16:59