How to add UIToolbar to a NavigationController on Storyboard?
Asked Answered
T

2

8

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?

Troxell answered 28/8, 2014 at 13:0 Comment(0)
F
2

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

Foolhardy answered 28/8, 2014 at 13:31 Comment(3)
did not work. What is the point of that white rectangle at the bottom if Xcode does not allow anything to be dragged there?Troxell
it was a problem on the storyboard. I recreated and it worked. Thanks.Troxell
If a tool bar is not appropriate for a navigation controller, then why does a navigation controller have "Show Toolbar" option?Sanches
D
1

Try this :

You just drag and drop the UINavigationItem on UINavigation RootViewController instead of UIToolbar.

It will allow you to put UIBarButtonItem on that UINavigationItem and works same like UIToolbar Button.

Dialectic answered 28/8, 2014 at 13:22 Comment(3)
Can you answer with pictures of interface builder?Troxell
Hi RubberDuck, Here the image link [(i.imgur.com/HIDUjj7.png?1)] with specification.Dialectic
This gives you a navigation bar, not a toolbar.Shingles

© 2022 - 2024 — McMap. All rights reserved.