开发者

How to access to navigationItem when I am in a view controller in tabBar?

开发者 https://www.devze.com 2023-02-20 00:00 出处:网络
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.

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" ];

开发者_如何学Python

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消