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.

  • I have added a storyboard to the project
  • I have added a navigation controller to it
  • 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).
  • 在这里输入图像描述

    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:

    在这里输入图像描述

    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:

    在这里输入图像描述

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

    How do I make the button show?


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

    Try in an UIViewController and that will work !

    Edit:

    在这里输入图像描述在这里输入图像描述


    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.

    链接地址: http://www.djcxy.com/p/81212.html

    上一篇: C ++

    下一篇: 如何将UIToolbar添加到Storyboard上的NavigationController?