From the documentation UIViewController+UINavigationControllerItem, see below, we should use the property navigationItemdirectly on the view controller:
@property(nonatomic,readonly,strong) UINavigationItem *navigationItem;
UINavigationControlleralso has a property navigationItem, since it inherits from UIViewController, but setting it will not affect the navigation properties of the view controller.
From a quick test, we see that these navigation elements are not equal:
(lldb) po self.navigationItem
<UINavigationItem: 0x7f865c99ec50>
(lldb) expr -- @import UIKit
(lldb) po self.navigationController.navigationItem
<UINavigationItem: 0x7f865c811740>
source
share