I am trying to add Home button to navigation controller. Therefore I created below class and sub classed my navigation controller. My button appears on my first view. When I navigate to other view(table view in my picture), added button disappears. I am using segues to push to another view.
class ThemedNavigationController: UINavigationController {
override func viewDidLoad() {
super.viewDidLoad()
var home = UIBarButtonItem(image: UIImage(named: "home"), style: UIBarButtonItemStyle.Plain, target: self, action: "doneAction")
navigationBar.topItem?.rightBarButtonItem = home
navigationBar.barTintColor = anaRenk
navigationBar.barStyle = .Black
navigationBar.titleTextAttributes = [NSFontAttributeName: UIFont(name: sansSerifName, size: 17)!]
UIBarButtonItem.appearance().setTitleTextAttributes(
[NSFontAttributeName: UIFont(name: sansSerifName, size: 17)!],
forState: .Normal)
}
func doneAction() { // [6]
self.navigationController?.popToRootViewControllerAnimated(true)
}
}
Before my mainViewController didn't have navigation controller. Instead each button was pushing new viewcontrollers which had separate navigation controllers and my code was working. I will appreciate if you can tell me how can I fix this issue.