I am not able to show a back bar button item in my navigation item in my root view controller of my navigation controller.
I have tried setting different properties.
Other questions like this do not give me an answer that works.
Her is my code in my root view controller:
override func viewDidLoad() {
super.viewDidLoad()
print("viewDidLoad")
navigationItem.leftItemsSupplementBackButton = true
navigationItem.backBarButtonItem = UIBarButtonItem(title: "Button", style: .plain, target: nil, action: nil)
navigationItem.setHidesBackButton(false, animated: true)
navigationItem.leftItemsSupplementBackButton = true
}
Assigning to leftBarButtonItem
instead of backBarButtonItem
works for me:
override func viewDidLoad() {
super.viewDidLoad()
print("viewDidLoad")
navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Button", style: .plain, target: nil, action: nil)
}