简体   繁体   中英

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM