Could anyone explain why there are two navigationItems
? When I log like below:
NSLog(@"%@", self.navigationItem);
NSLog(@"%@", self.navigationController.navigationItem);
I get two different instances of UINavigationItem
:
<UINavigationItem: 0x7f85b06f5a20>
<UINavigationItem: 0x7f85b06ab640>
I have only created a UINavigationController
programmatically once.
All
UIViewController
s have a propertynavigationItem
. Therefore, becauseUINavigationController
is a subclass ofUIViewController
, it also has this property.self.navigationItem
will be the one presented when your controller is pushed. The documentation fornavigationItem
, it's clear about this propertyself.navigationController.navigationItem
would be the item displayed if Apple allowedUINavigationController
s to be nested. However, since this isn't allowed, it's best to forget about it.