UINavigationController 工具栏按钮
我有一个 UINavigationController,我已将其设置为窗口的 rootViewController。在 NIB 文件中,我对其进行了设置,使其具有“工具栏”的“底栏”。在 Interface Builder 中,我添加了一个 UIBarButtonItem。这一切都很好,我可以很好地处理按钮点击。当我点击其中一个按钮时,我将一个新视图推送到 ViewController 上,这也工作得很好。有一个问题,加载视图时我的按钮消失了。现在,在后续视图中,我可以将底部栏设置为工具栏,并在 Interface Builder 中看到它,但我无法向其中添加任何按钮。
我知道我要么错过了一些明显的东西,要么错误地思考了这一点,但是如何将 UIBarButtonItems 添加到推送到导航控制器的后续视图中?我说的是底部的导航栏,而不是顶部的导航栏。
有什么想法吗?
I have a UINavigationController that I've set as the rootViewController of my window. In the NIB file I've set it up so that it has a "Bottom Bar" of "Toolbar". In Interface Builder I've added a UIBarButtonItem. This all works great and I can handle the button click fine. When I hit one of the buttons, I push a new view onto the ViewController and that works fine too. One problem, my button disappears when the view is loaded. Now in the subsequent view I can set the bottom bar to be a Toolbar and I see it in Interface Builder, but I cannot add any buttons to it.
I know I'm either missing something obvious or thinking about this incorrectly but how do I add UIBarButtonItems to subsequent views pushed to my nav controller? I'm talking the bar at the bottom, not the nav bar at the top.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
UIViewController 上的toolBarItems 属性是您感兴趣的。您可以以编程方式创建UIBarButtonItems 并将它们添加到viewDidLoad 中的新toolBarItems 数组中。
The toolbarItems property on the UIViewController is what you are interested in. You can create UIBarButtonItems programmatically and add them to a new toolBarItems array in viewDidLoad.
这对我来说效果更好:
你可以对右侧做同样的事情。
This worked better for me:
You can do the same for the right side.