I want to change the title of navigation bar but it seems somewhat confusing..
I did self.navigationItem.title = "ipsum"
or self.navigationController?.navigationBar.topItem?.title = "ipsum"
and so on.. but it fails..
It only succeeds changing the title when trying self.title = "ipsum"
but it is not what I want because it causes tabBarItem's title to change too.
I tried debugging and found out strange result.
as you see the picture above.. there seems to be more than two navigationBar so when self.navigationItem.title = "ipsum"
it actually changes some other or invisible navigationItem's title so that I can see from the log.
But the UI stays "lorem". Tell me if you figure something out! What am I missing?
EDIT 1:
I put NavigationController in TabBarController and refactored NavigationController to another storyboard reference.
self.navigationItem.title = "ipsum"
is called in the viewDidLoad() function.
Now View controllers are:
ViewController1 attached to item1:
override func viewDidLoad() {
super.viewDidLoad()
self.navigationItem.title="View1"
}
ViewController2 attached to item2:
override func viewDidLoad() {
super.viewDidLoad()
self.navigationItem.title="View2"
}
Result: