Dynamically set navigation controller header

I work with master data, and part of my application is very similar to the default contacts application. After the contact, there is an edit screen in the main data, and I would like to make the header: [insert contact name here] s information. "I know that I can set the header only for the main data item by doing: self.navigationController.title = _athletesFullName ; (property for the attribute under the "Athlete" object). Is there a way to do something like

self.navigationController.title = @"%@ information",_athletesFullName; ? 
+4
source share
3 answers

try this code:

  self.navigationController.navigationItem.title=[NSString stringWithFormat:@"%@ information",_athletesFullName]; 
+8
source

self.navigationItem setTiltle: is the usual way. The navigationItem has been added by an interface constructor that you will embed in your viewController.

+2
source

If you know the index of your navController, you can change your navTitle as follows:

 UINavigationController *navc = (UINavigationController)[self.navigationController.viewControllers objectAtIndex:1]; navc.navigationItem.title = @"Yout Title"; 

OR

Try using:

 self.navigationController.navigationBar.topItem.title = @"Your Title"; 
0
source

Source: https://habr.com/ru/post/1496308/


All Articles