Search code examples
ioscocoa-touchuinavigationcontrolleruistoryboarduitoolbar

How to add UIToolbar to a NavigationController on Storyboard?


I am not a huge fan of using Interface Builder and for that reason I am new to it.

I am trying to add a UIToolbar to a navigation controller but because Apple documentation is always very clear, I don't have a clue.

I am converting an old project to use Storyboards.

This is what I have done.

  1. I have added a storyboard to the project
  2. I have added a navigation controller to it
  3. Because I want this navigation controller to show a toolbar at the bottom, I have clicked on the navigation controller and turned the toolbar on (see pic).

enter image description here

after that, a white rectangle appeared at the bottom of the navigation controller on interface builder. I think this is a the UIToolBar or a placeholder. I have tried to drag a BarButtonItem to this "space" and Xcode allowed, showing it like this:

enter image description here

When I run the app, the toolbar shows as a white rectangle at the bottom but not the button.

The button shows like this on the hierarchy:

enter image description here

I suppose the button should be inside the Toolbar item, but Xcode forbids dragging the item there.

How do I make the button show?


Solution

  • The problem here is that your are trying to add an UIToolBar in a UINavigationController ...

    Try in an UIViewController and that will work !

    Edit:

    enter image description here enter image description here