I have the following viewDidLoad override in my subclass of UIViewController that's embedded in a Navigation Controller. I have un-hidden the toolbar, and when I run, the toolbar is there (which confirms that I am inside a navigation controller and that I'm addressing it correctly), but I can't get any buttons to show. What am I doing wrong here?
override func viewDidLoad() {
super.viewDidLoad()
var buttons = [UIBarButtonItem]()
for title in buttonTitleArray {
let plainButton = UIBarButtonItem(title: title, style: .plain, target: self, action: #selector(self.setContentMode(_:)))
let systemButton = UIBarButtonItem(barButtonSystemItem: .play, target: self, action: #selector(self.setContentMode(_:)))
buttons.append(plainButton)
buttons.append(systemButton)
}
self.navigationController?.toolbarItems = buttons
self.navigationController?.isToolbarHidden = false
}
I've tried adding the buttons using self.navigationController?.setToolbarItems(buttons, animated: false) but that doesn't work either.