iOS - Toolbar not showing
Asked Answered
C

4

18

Using the storyboard I created a new screen for a second View controller and added a Toolbar at the bottom. But when the view is shown, the toolbar doesn't appear. I'm using Segue to change views.

What could be wrong?

Chuff answered 13/2, 2012 at 23:44 Comment(0)
M
58

If you're using a Navigation Controller, make sure to tick "Shows Toolbar" and add the buttons there, not on a standalone toolbar.

In order to show only on some, you'll need 2 different views, one that will hide it and another that won't and add the following to the respective view's viewWillAppear:

    self.navigationController.toolbarHidden = YES;

(Set to YES to hide, NO to show)

You can play around with the Simulated Metrics on the Storyboard so as to visually simulate the run-time effect by setting Bottom Bar to either None or Toolbar instead of inferred, as appropriated.

EDIT: Check this sample project I made.

Mauri answered 14/2, 2012 at 0:2 Comment(6)
Yeah, I'm using a Navigation Controller, but I want to show the Toolbar only in one view. Is it possible?Chuff
Yes: you need to have a different class for that view and add the following to the viewWillAppear method:Mauri
I've edited the answer as comments are a bit more limited and can't edit them after 5 mins.Mauri
Weird: works just fine in a test project I made. I'll upload it somewhere and add the link here.Mauri
Added the sample project in the answer.Mauri
+1.. Great sample project. To sum it up, two things to remember. 1. set navController's toolbarHidden property in viewWillAppear 2. set attributes inspector -> Bottom bar to None / Toolbar as needed.Glutamate
O
5

Select the Navigation Controller in the storyboard. Under Bar Visibility, check "Shows Toolbar".

Occult answered 28/3, 2012 at 20:54 Comment(0)
W
4

try this

self.navigationController.toolbarHidden=NO;
Wreak answered 14/2, 2012 at 0:1 Comment(1)
This worked, but it shows only the Navigation Controller toolbar. Is there a way to show the view specific toolbar?Chuff
T
2

In the show the size inspector in the field autosizinf choose to bind to the top of the screen and remove the binding to the bottom of the screen.

Theoretics answered 17/2, 2014 at 3:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.