Question

I'm using custom titleView for navigation bar in viewDidLoad, here is my code:

UILabel *titleView = [[UILabel alloc] initWithFrame:CGRectMake(50, 0, 220, 44)];
titleView.text = @"Hello";
titleView.textAlignment = NSTextAlignmentCenter;
self.navigationItem.titleView = titleView;

But I want to change this title text later programmatically, I tried couple ways with no success.

self.navigationItem.titleView.text = @"Loading...";
self.navigationItem.title = @"Loading...";

How do I change the title text in custom titleView ?

No correct solution

OTHER TIPS

If the initial code works you should allocate a new label, set its text and reset it and that should probably work.

Alternatively store the label as a property and try setting its title from self.label.text = @"..."

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top