iPhone——向用户在 moreNavigationController 中选择选项卡时创建的导航栏添加一个按钮
我的标签栏有十个标签。因此,其中六个被推入“更多”选项卡。其中一些没有 UINavigationControllers。即,该选项卡由 UIViewController 子类控制,该子类不是导航控制器。
当用户选择其中之一时,相应的视图控制器就会出现,顶部有一个 UINavigationBar。
我想向该导航栏添加一个按钮。我怎样才能做到这一点?
谢谢。
My tab bar has ten tabs. Six of these are therefore shoved into the "More" tab. Several of them do not have UINavigationControllers. I.e, the tab is controlled by a UIViewController subclass that is not a navigation controller.
When the user selects one of these, the appropriate view controller come sup, with a UINavigationBar at the top.
I want to add a button to that navigation bar. How can I do that?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,如果您想以编程方式执行此操作,那么我建议将 UITabBar 中的每个 viewController 替换为容纳相应视图控制器的 UINavigationController。
所以,你的旧代码看起来像这样:
新代码应该是:
Well, if you want to do this programmatically, then I would suggest replacing each of your viewControllers in your UITabBar with UINavigationControllers that house the respective view controllers.
So, your old code looks something like this:
New code should be:
有两种方法可以解决这个问题。
只需为每个选项卡使用 UINavigationController,并在其中包含视图控制器。但听起来您不想这样做,所以:
使用 Interface Builder 放置一个 UINavigationBar。 导航栏 http://cl.ly/395fb8c0a9e9df781897/content
然后,您可以拖入 UIBarButtonItems 并根据您的喜好配置它们,也在 IB 中。 按钮 http://cl.ly/7501d3e8e5d57dac5e00/content
There are two ways to go about it.
Just use a UINavigationController for each tab, with your view controller in it. But it sounds like you don't want to do this, so:
Put a UINavigationBar in using Interface Builder. nav bar http://cl.ly/395fb8c0a9e9df781897/content
You can then drag in UIBarButtonItems and configure them to your liking, also in IB. buttons http://cl.ly/7501d3e8e5d57dac5e00/content