David
David

Reputation: 2810

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

Upvotes: 5

Views: 4054

Answers (2)

David
David

Reputation: 2810

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.

Upvotes: 1

Levi
Levi

Reputation: 7343

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

Upvotes: 13

Related Questions