Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between self.navigationController.navigationItem and self.navigationItem

What is the difference between self.navigationController.navigationItem and self.navigationItem? I am using a UINavigationController throughout the app and when I use self.navigationController.navigationItem.rightBarButtonItems, in one of the viewDidLoad methods of one of the viewControllers, the array is empty. However if I use self.navigationItem.rightBarButtonItems, I see my bar button items. What is the difference between the two calls? Thanks!

like image 330
Crystal Avatar asked Jun 25 '12 21:06

Crystal


1 Answers

A UINavigationController is a subclass of UIViewController. As such, it has its own independent navigationItem property, which it inherited from UIViewController. You should ignore this property, as it would only be used if you were to embed a navigation controller inside another navigation controller (which nobody in their right mind would ever do).

like image 132
Lily Ballard Avatar answered Sep 30 '22 15:09

Lily Ballard