向ios导航栏添加按钮
我正在尝试向导航栏添加两个右侧按钮。我尝试使用以下方式添加,但我得到 SIGABRT
self.navigationController.navigationBar.items = navItemsArray;
self.navigationItem.rightBarButtonItems = navItemsArray;
< code>navItemsArray 有两个 UIBarButtonItem
类型的按钮。
谁能帮忙解决这个问题吗?我不知道出了什么问题。
I am trying to add two right buttons to the navigation bar. I tried adding using following ways but I get SIGABRT
self.navigationController.navigationBar.items = navItemsArray;
self.navigationItem.rightBarButtonItems = navItemsArray;
navItemsArray
has two buttons of type UIBarButtonItem
.
Can anyone help with this? I can't figure out what is wrong.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
仅适用于 iOS 5。
works only in iOS 5.
你有按钮的回调吗?您是否通过按住 Option 键单击按钮并将其拖动到某处来“连接”按钮?
您需要将按钮连接到 IBAction。
do you have callbacks for the buttons? Did you "wire up" the buttons by option-clicking them and dragging them to something?
You need to have the buttons connected to an IBAction.
您不能在
UINavigationBar
中直接添加两个UIBarButtonItem
。但使用UIToolBar
可以达到与导航栏相同的效果。您可以在UIToolBar
中添加任何控件,例如 switch、segmentedControl 等。有关代码的更多帮助,请参阅上一篇文章 Link1 和 Link2
You cannot add directly two
UIBarButtonItem
inUINavigationBar
. But useUIToolBar
to have same effect as of Navigation Bar. You can add any controls inUIToolBar
Such as switch, segmentedControl etc.For more help on Code please refer the previous post Link1 and Link2