Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 560
Duck Avatar asked Aug 28 '14 13:08

Duck


2 Answers

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 hereenter image description here

like image 149
Nicolas Bonnet Avatar answered Nov 10 '22 00:11

Nicolas Bonnet


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.

like image 42
Gautam Sareriya Avatar answered Nov 10 '22 01:11

Gautam Sareriya