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!
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With