Reputation: 12952
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 ?
Upvotes: 2
Views: 1657
Reputation: 3718
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 = @"..."
Upvotes: 1