使用导航栏获得类似于 iPhone Safari 应用程序中选择器的功能?
在 Safari 中,当我按下下拉框时,选择器顶部会出现一个导航栏,其中有一个完成按钮和一些其他按钮。
我想要一个类似的栏,在选择器视图上方有两个按钮,但我不知道如何在栏上放置按钮。对于导航控制器,我会这样做:
self.navigationItem.rightBarButtonItem = [UIButton .....
self.navigationItem.backBarButtonItem = [UIButton ......
但是我在以编程方式创建的导航栏上找不到任何按钮属性。添加按钮作为子视图似乎也没有做任何事情。我怎样才能添加它们?
In Safari, when I press a dropdown box, a picker comes up with a navigation bar on top of it that has a done button and some other buttons.
I want a similar bar with two buttons above my picker view, but I can't figure out how to put buttons on the bar. With a navigation controller, I'd do:
self.navigationItem.rightBarButtonItem = [UIButton .....
self.navigationItem.backBarButtonItem = [UIButton ......
But I'm not finding any button properties on the navigation bar that I'm creating programmatically. Adding the buttons as subviews also doesn't seem to be doing anything. How can I add them?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个工具栏,而不是导航栏。设置其
items
属性以使用 UIBarButtonItem 对象填充它。请注意,它们与 UIButton 不同,实际上甚至不是 UIView 的子类;他们有自己的一套属性。一个简单的例子:It’s a toolbar, not a navigation bar. Set its
items
property to populate it with UIBarButtonItem objects. Note that those are not the same as UIButtons, and in fact don’t even subclass from UIView; they have their own set of attributes. A simple example: