I am reading about UINavigation controller, and it makes sense to have a navigationItem in the NavigationController,
but when I create a UIViewController, there is also a property called navigationItem from type UINavigationItem
so now I have :
self.navigationController!.navigationItem.title = "test2"
self.navigationItem.title = "test"
The point is that all
UIViewControllers have a
UINavigationController decides what to show in its
navigationBar by looking at the current viewController's navigationItem.
So you get this;
vcA.navigationItem.title = "A" vcB.navigationItem.title = "B" navigationController = UINavigationController(rootViewController: vcA) // The title in the navigationBar is now "A" navigationController.pushViewController(vcB, animated: true) // The title in the navigationBar is now "B"
UINavigationController is also a subclass of
UIViewController, it inherits the navigationItem as well, even though it's useless in most cases.