简体   繁体   English

自定义UINavigationController中的UIBarButtonItem未显示

[英]UIBarButtonItem in custom UINavigationController not showing up

On my side menu I call a NavigationController for each item on didSelectRowAtIndexPath. 在侧面菜单上,我为didSelectRowAtIndexPath上的每个项目调用了NavigationController。

Because of that I have a few NavigationControllers. 因此,我有几个NavigationControllers。 So I created a custom UINavigationController to reuse the code. 因此,我创建了一个自定义UINavigationController来重用代码。

The thing is that my UINavigationController subclass is being called but nothing appears on the simulator. 事实是,我的UINavigationController子类正在被调用,但是模拟器上没有任何显示。

[self.sideMenuViewController setContentViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"EventsXib"]];

EventsXib is my CustomNavigationController EventsXib是我的CustomNavigationController

Any idea? 任何想法?

For the record, the whole point for me to do this is that I want the same leftBarButtonItem and 2 rightBarButtonItems on all my ViewControllers. 作为记录,我要做的全部事情是我希望在所有ViewController上使用相同的leftBarButtonItem和2 rightBarButtonItems。

UPDATED: 更新:

I noticed that this actually worked: 我注意到这确实有效:

self.navigationItem.leftBarButtonItem = self.navigationController.navigationItem.leftBarButtonItem;
self.navigationItem.rightBarButtonItems = self.navigationController.navigationItem.rightBarButtonItems;

But I still have to do this in every viewController, and thats not what I want. 但是我仍然必须在每个viewController中执行此操作,这不是我想要的。


Here is a general idea of what it looks like: 这是一个大概的外观:

在此处输入图片说明

As @GoGreen suggested, I created a base view controller with the corresponding buttons on the navigationItem. 正如@GoGreen所建议的那样,我在navigationItem上创建了带有相应按钮的基本视图控制器。

Its not the simple solution I had in my mind but it works pretty good. 这不是我想到的简单解决方案,但效果很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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