UIToolbar not showing UIBarButtonItem

后端 未结 1 874
别那么骄傲
别那么骄傲 2021-02-05 04:43

I\'m using a storyboard and I\'ve a split view where the master is a UITableViewController. Like the iPad Mail app, I\'d like to display a UIToolbar.

I wasn\'t able to a

相关标签:
1条回答
  • 2021-02-05 05:15

    Found the answer thanks to the Apple iOS Forum!

    When you use the toolbar of the navigation controller, you have to set the toolbar buttons on the active view controller's toolbarItems property, not on the actual navigation controller's toolbar itself.

    From the UINavigationController docs:

    Displaying a Toolbar

    A navigation controller object manages an optional toolbar in its view hierarchy. When displayed, this toolbar obtains its current set of items from the toolbarItems property of the active view controller. When the active view controller changes, the navigation controller updates the toolbar items to match the new view controller, animating the new items into position when appropriate.

    For example:

    [self setToolbarItems:buttons animated:NO];
    
    0 讨论(0)
提交回复
热议问题