Reputation: 91761
When I try to add a UIBarButtonItem to my UIViewController, nothing shows up at run time.
What I did:
Note: the Bar Button Item appears as a direct child of View Controller.
How can I get the UIToolbar to appear?
Upvotes: 2
Views: 2478
Reputation: 91761
Adding toolbar items as direct children of the UIViewController corresponds to the toolbarItems property of a view controller. The documentation states:
If this view controller is embedded inside a navigation controller interface, and the navigation controller displays a toolbar, this property identifies the items to display in that toolbar.
So, you must do the following:
self.navigationController.toolbarHidden = NO
in the view did load method).Optionally, if you want to restore the behavior where the navigation bar wasn't visible, then uncheck the Shows Navigation Bar property.
An alternative approach is to not use the toolbarItems property, and instead add your own toolbar and maintain it yourself (e.g. add an IBOutlet and interact with it that way).
Upvotes: 5