I don't understand what is the difference between
self.navigationcontroller.navigationitem
and self.navigationitem
i have navigation based application and in viewDidLoad
method in rootViewController
of navigationController I set the NavigationItem titleView to custom image by using this code
UIImageView* titleImage=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image.png"]];
self.navigationItem.titleView =titleImage;
by the way if i try to change titleview by this way
UIImageView* titleImage=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image.png"]];
self.navigationcontroller.navigationItem.titleView =titleImage;
nothing was happened.
, and when navigationcontroller pushed the another view to the stack the titleview of navigationitem is cleared and reference sets to nil, and also i noticed that the references of self.navigationcontroller.navigationitem
and self.navigationitem
are not the same.
I believe what you are asking is the following: self.navigationController.navigationItem
and self.navigationItem
. I am ignoring the rest of the question since it is not really essential to the question.
From what I understand self.navigationController.navigationItem
is useless since it is accessing navigation item of the navigation controller (ie your rootViewController).What you really want is self.navigationItem
, navigation item of the view controller because that is what essentially going to show up in your view controller.
UINavigationController
is a subclass of UIViewController
so self.navigationController.navigationItem
is just a spillover method from subclassing. It does not do anything positive (at least in my experience).
Edit: Read this for further clarification.
They are Different. If you dynamically add UINavigationController
, then you use self.navigationController.navigationItem
.
Please better clarify your question.
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