2

I added (or show) a Toolbar on the Navigation Controller with the "Show Toolbar" checkbox in the Attributes Inspector in Xcode 6.2.

Because

The custom toolbar associated with the navigation controller. (read-only)

I'm using self.navigationController?.setToolbarItems(items, animated: true) to add my items to the toolbar (items is a NSArray) but the toolbar doesn't show up any items so far. To test a few things I tried to add a single UIBarButtomItem which is created this way:

testBarButtonItem = UIBarButtonItem(title: "testTitle", style: .Plain, target: nil, action: nil)

The code is inside the override func viewDidLoad() of a UIViewController.

I already debugged my code to find out if there is a nil around but neither the UIBarButtonItem nor the navigationController are nil.

1 Answer 1

4

Use self.toolbarItems of the viewcontroller itself. Do not manipulate the toolbar of the navigation controller directly.

(I've not used self.toolbarItems in a while so im not 100% positive, but I guess it works like for self.navigationItem.leftBarButtonItems and .rightBarButtonItems)

EDIT: Or there should also be a method setToolbarItems:animated (on the UIViewController, not the UINavigationController) which is perhaps better.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.