1

我有 UINavigationController 并在其中放置了 UIListView。现在我想在导航栏的左侧添加多个 BarButtons。这怎么可能?我设法通过代码在那里添加了一个按钮,但没有添加多个。

编辑:通过 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 ...

4

2 回答 2

1

您可以这样做的唯一方法是将 UIBarButtonItem 添加到 UIToolBar 并使用 UIToolBar 作为 customView 制作 UIBarButtonItem。

网上有很多例子,看看: http: //osmorphis.blogspot.com/2009/05/multiple-buttons-on-navigation-bar.html

于 2011-06-18T04:39:14.520 回答
1

iOS 5.0 has apis to do this. Check the following properties of UINavigationItem Class

leftBarButtonItems 

rightBarButtonItems

leftItemsSupplementBackButton
于 2012-01-18T06:57:10.970 回答