Trying to modify title in a UINavigationItem
// this modify the title
self.navigationItem.title = @"Any title";
// this does not
navigationItem.title = @"Any title";
Why?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
navigationItemis not the object it’s using.self.navigationItemis a readonly property created on demand when using aUIViewControllerwith aUINavigationController. You can certainly create customUINavigationItembut thats often frowned upon in a standardUINavigationControllersetup, and you shouldn’t need to.As for
self.title, its merely a shortcut toself.navigationItem.title. The reason for the shortcut is it can be used elsewhere in other containment types if necessary including you own custom containers.If you deconstruct what is happening. it is likely that this is happening, loading your title if you access a navigationItem, which a basic UINavigationController would:
You can read more on what Apple has to say about it here: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instp/UIViewController/navigationItem