I want to get rid of the title on a navigation bar's back button. It keeps crowding the title of my view controller.
How do I hide it using Swift 3?
This doesn't work:
self.navigationController?.navigationItem.backBarButtonItem?.title = nil
I want to get rid of the title on a navigation bar's back button. It keeps crowding the title of my view controller.
How do I hide it using Swift 3?
This doesn't work:
self.navigationController?.navigationItem.backBarButtonItem?.title = nil
 
    
    Add either
self.navigationItem.backBarButtonItem = UIBarButtonItem(title:"", style:.plain, target:nil, action:nil)
or
self.navigationController?.navigationBar.backItem?.title = ""
to your prepare:forsegue: if you use storyboard or before navigating.
 
    
    THIS WORKS:
I had to put:
self.navigationItem.title = ""
That's it. If anybody can explain why this works, and the other posted answers don't, that'd be great!
 
    
    It works for me . . replace nil with "" (Swift 3)
 self.navigationController?.navigationItem.backBarButtonItem?.title = "" 
 
    
    Check this out:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let backItem = UIBarButtonItem()
backItem.title = "Back"
navigationItem.backBarButtonItem = backItem // This will show in the next view controller being pushed
}
More detail: https://stackoverflow.com/a/32284525/4935811
 
    
    Lets say you have A ViewController pushes B ViewController. And you wan't to remove the back button title in ViewController B. Then You need to set the backBarButtonItem of the A ViewController. Something like this.
class AViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        self.navigationItem.backBarButtonItem = UIBarButtonItem(title:"", style:.plain, target:nil, action:nil)
    }
}
