Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change title of UINavigationController thats currently being displayed

I have a view currently displayed by a UINavigationController. When the user changes a selection elsewhere, I need the currently displayed title displayed by the UINavigationController to change. Even though I change the title in the current view controller, I can't get the UINavigationController to refresh the title.

I've tried all sorts of things and have not been successful changing the title.

I am doing a [tableview reloadData] for the rest of the view, but that's not changing the title.

In the view controller being displayed, I've tried the following

self.title = @"New title";

I've tried various combinations of setNeedsDisplay, setNeedsLayout on both the self.view and self.navigationController.view.

Nothing has successfully changed the title on the nav bar.

Thanks

like image 563
David Avatar asked Jan 02 '13 21:01

David


2 Answers

Try setting self.navigationItem.title to the desired value.

like image 151
Levi Avatar answered Oct 17 '22 01:10

Levi


I had forgotten that I was overriding titleView. So I didn't need to set the title, but change the titleView. Once I did that, its working fine.

like image 39
David Avatar answered Oct 17 '22 01:10

David