0
votes

I have a tab bar controller that has 5 tabs, each with a navigation controller embedded in. There are times where I need to display a view controller from another tab.

I am overriding the stock back button text < BACK to just have it say <, which I do using

let backItem = UIBarButtonItem()
backItem.title = ""
navigationController?.navigationBar.tintColor = UIColor.whiteColor()
navigationItem.backBarButtonItem = backItem

However, when I load a view controller from a different tab bar (with a different navigation controller), I can't figure out how to remove the < BACK from the supplementary navigation controller so I can just display the button as <. Putting the above code in prepareForSegue: works with one nav controller, but not when there is a second one. Thanks a lot, any insight is greatly appreciated!

1

1 Answers

1
votes

The back button that you see when a view controller is pushed onto the navigation controller's stack belongs, not to the pushed view controller, but to the previous view controller, the one that was showing before the push.

If that view controller says:

self.navigationItem.backBarButtonItem = 
    UIBarButtonItem(title: "", style: .Plain, target: nil, action: nil)

... then when a view controller is pushed on top of it, the back button will show no title.