[英]How to access to navigationItem when I am in a view controller in tabBar?
I have view controllers in a tabBar. 我在tabBar中有视图控制器。 And the tabBar is in navigationController.
tabBar位于navigationController中。 I want to access to navigationItem when I am in a view controller in tabBar.
我在tabBar的视图控制器中时想访问navigationItem。 Usually, when I set a navigationItem's title, I used to doing this.
通常,当我设置navigationItem的标题时,我曾经这样做。 (if I am in a viewController)
(如果我在viewController中)
[ [ self navigationItem ] setTitle: @"Menu" ];
But I am in a view controller in tabBar in navigation controller, this way doesn't work. 但是我在导航控制器的tabBar中的视图控制器中,这种方式不起作用。
A view controller has a navigationItem property. 视图控制器具有navigationItem属性。 But, although view controllers in tabBar has a navigationItem property, that doesn't work.
但是,尽管tabBar中的视图控制器具有navigationItem属性,但这是行不通的。 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. 标签栏控制器中的控制器通过
tabBarController
属性持有对该控制器的引用。
In CVC
, you can access the navigation item like this: self.tabBarController.navigationItem
. 在
CVC
,您可以像这样访问导航项: self.tabBarController.navigationItem
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.