Reputation: 1081
I have a navigation bar with tableview, when I choose one of the cells of tableview it leads me to another table view with title of the cell chosen, and also I use page view controller for the these tableviews.
I set title of navigation bar for the root table in viewcontroller of the first tableview as:
override func viewDidLoad() {
self.navigationItem.title = "TableView Title"
}
I set the title of bar after choose the cell in the view controller of second tableview as:
override func viewDidLoad() {
self.navigationController?.navigationBar.topItem?.title = "chosen cell text"
}
override func viewDidAppear(animated: Bool) {
self.navigationController?.navigationBar.topItem?.title = "chosen cell text"
}
With these codes, it sets root tableview's title properly.
But when I choose a cell. root table's title is appear in back button. And there is no other title.
When I go next page of second tableview, the title of the second tableview appear properly. Therefore why the second tableview's title doesnot appear, when it first appears. How can I invoke it?
Solution: Firstly thanks for your help. I try to change the title in page viewer controller by self.navigationItem.titleView = "chosen cell text"
and it works.
Upvotes: 0
Views: 800
Reputation: 196
Set the title property of the Child View Controller itself.
Example:
override func viewDidLoad() {
super.viewDidLoad()
self.title = "Chosen Cell Text"
}
Upvotes: 1