I'm trying to put a rightBarButtonItem on a second view controller of an UINavigationViewController stack.
I'm creating and setting the button in viewDidLoad of the view controller that I want to show. My actual code looks like this:
override func viewDidLoad() { super.viewDidLoad() menu_button_ = UIBarButtonItem(image: UIImage(named: "menu"), style: UIBarButtonItemStyle.Plain , target: self, action: "OnMenuClicked:") self.navigationController!.navigationItem.rightBarButtonItem = menu_button_ } What am I missing? The button doesn't appear.
You should set the menu_button_ as the rightBarButtonItem of your viewController rather than the navigationController.
Try
self.navigationItem.rightBarButtonItem = menu_button_ instead of
self.navigationController!.navigationItem.rightBarButtonItem = menu_button_
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With