Alec. Alec. - 2 months ago 29
iOS Question

Back button showing on root view controller

In my application I have a navigation controller. Everything appears to be working fine apart from I keep getting an unwanted back button in my root view. For example

This is how it appears without selecting any options (how it needs to be always)
enter image description here

This is how it looks after I select an option and go back

enter image description here

How can I get rid of the back button (on the root view controller shown below only)?


Just hide your back button in the specific view controller (in your case your root view controller). Add this code to your viewDidLoad() method:

let backButton = UIBarButtonItem(title: "", style: .plain, target: navigationController, action: nil)
navigationItem.leftBarButtonItem = backButton