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
UIViewControllers have a propertynavigationItem. Therefore, becauseUINavigationControlleris a subclass ofUIViewController, it also has this property.self.navigationItemwill be the one presented when your controller is pushed. The documentation fornavigationItem, it's clear about this propertyself.navigationController.navigationItemwould be the item displayed if Apple allowedUINavigationControllers to be nested. However, since this isn't allowed, it's best to forget about it.