How to access to navigationItem when I am in a view controller in tabBar?
I have view controllers in a tabBar. And the tabBar is in navigationController. I want to access to navigationItem when I am in a view controller in tabBar. Usually, when I set a navigationItem's title, I used to doing this. (if I am in a viewController)
[ [ self navigationItem ] setTitle: @"Menu" ];
But I am in a view controller in tabBar in navigation controller, this way doesn't work.
A view controller has a navigationItem property. But, although view controllers in tabBar has a navigationItem property, that doesn't work. I think that it is right logically.
Thank you for reading my question.
Assuming your view controller hierarchy looks like
> UINavigationController
> UITabBarController
> CustomViewController (CVC)
Controllers in a tab bar controller hold a reference to this controller via the tabBarController
property.
In CVC
, you can access the navigation item like this: self.tabBarController.navigationItem
.
精彩评论