Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

self.title vs self.navigationItem.title

Tags:

What is the purpose of the title property of UIViewController, can't the title already be set with navigationItem.title ?

Both seem to work, I'm just wondering why there's this seemingly duplicated functionality.

like image 952
Jaka Jančar Avatar asked Jun 06 '09 19:06

Jaka Jančar


1 Answers

In a UIViewController, title and navigationItem.title are different. One example: if you have a view controller (in a NavigationController) in a UITabBarController, then if you set self.title it overrides the name of the tab as well as the top title. If you set self.navigationItem.title then it only changes the top title, leaving the tab bar name unchanged.

like image 90
Peter Avatar answered Sep 20 '22 16:09

Peter