iPad - 多个 UIBarButtonItem
我有 UINavigationController 并将 UIListView 放置在其中。现在我想在导航栏的左侧添加多个 BarButton。这怎么可能?我设法通过代码在那里添加一个按钮,但不是多个。
编辑:通过 IB 添加到 UINavigationController 的 NavigationBar 的按钮根本不可见。什么可能导致问题?
我在 .h 文件中创建了 UINavigationController 并在 .m 中使用了它并推送了另一个视图(即 TableView):
navigationController = [[UINavigationController alloc] init];
[window addSubview:[navigationController view]];
tableOfContents *tableOfContentsViewController = [[tableOfContents alloc] init];
[navigationController pushViewController:tableOfContentsViewController animated:NO];
[tableOfContentsViewController release];
编辑 2: 我解决了第二个问题。所以只剩下第一个问题了。多个 BarButtonItems ...
I have UINavigationController and I`ve placed UIListView in it. Now I want to add multiple BarButtons to left side of navigation bar. How is that possible? I managed to add one button there via code but not multiple.
Edit: Buttons added via IB to NavigationBar of UINavigationController aren`t visible at all. What could cause the problem?
I`ve created UINavigationController in .h file and used this in .m and pushed another view (that TableView):
navigationController = [[UINavigationController alloc] init];
[window addSubview:[navigationController view]];
tableOfContents *tableOfContentsViewController = [[tableOfContents alloc] init];
[navigationController pushViewController:tableOfContentsViewController animated:NO];
[tableOfContentsViewController release];
Edit 2: I solved second problem. So the first question only remains. Multiple BarButtonItems ...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
iOS 5.0 有 api 来执行此操作。检查 UINavigationItem 的以下属性类
rightBarButtonItems
iOS 5.0 has apis to do this. Check the following properties of UINavigationItem Class
rightBarButtonItems
执行此操作的唯一方法是将 UIBarButtonItem 添加到 UIToolBar 并使用 UIToolBar 作为自定义视图创建 UIBarButtonItem。
网上有很多例子,可以看看:
http://osmorphis.blogspot.com/2009/05 /multiple-buttons-on-navigation-bar.html
The only way you can do this is to add the UIBarButtonItem to a UIToolBar and make a UIBarButtonItem with the UIToolBar as the customView.
There are many examples on the web, check out:
http://osmorphis.blogspot.com/2009/05/multiple-buttons-on-navigation-bar.html