Iphone 显示导航控制器上的工具栏按钮
嗨,我知道我错过了一些东西,因为在整个网络上看起来都很容易。 我正在向工具栏添加按钮,Iphone 显示导航控制器上的工具栏按钮,iphone,ios,uinavigationcontroller,uitoolbar,Iphone,Ios,Uinavigationcontroller,Uitoolbar,嗨,我知道我错过了一些东西,因为在整个网络上看起来都很容易。 我正在向工具栏添加按钮, 工具栏正在显示。但是没有任何按钮。 这是我的代码: - (void)viewDidLoad { [super viewDidLoad]; self.title = @"secondPage"; UIBarButtonItem *deleteAllItem = [[[UIBarButtonItem alloc] initWithTitle:@"Delete All"
工具栏正在显示。但是没有任何按钮。
这是我的代码:
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"secondPage";
UIBarButtonItem *deleteAllItem = [[[UIBarButtonItem alloc] initWithTitle:@"Delete All"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(deleteAllAction:)] autorelease];
UIBarButtonItem *searchNearbyItem = [[[UIBarButtonItem alloc] initWithTitle:@"Search Nearby"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(searchNearbyAction:)] autorelease];
[self.navigationController setToolbarHidden:NO];
self.toolbarItems = [NSArray arrayWithObjects:
deleteAllItem,
searchNearbyItem,
nil];
}
感谢您的帮助您是否尝试通过以下方式设置项目:
- (void)setItems:(NSArray *)items animated:(BOOL)animated
注意:确保在视图控制器上设置,不要直接在
UIToolbar
实例上设置。谢谢,但这会将它们添加到导航栏中,我想将它们添加到底部的工具栏中我创建了一个新的基于导航控制器的项目,将此代码作为viewDidLoad复制到RootViewController上,并且它第一次工作。你能给我讲一点背景吗。你是在根控制器上尝试此操作吗?是的,你是对的,它在我的rooViewController:S上也适用。这很奇怪,我得到了它,在我的测试中,我添加了方法-(void)setToolbarItems:(NSArray*)toolbarItems animated:(BOOL)animated
,因此它覆盖了初始方法:S。。。很抱歉问你这个问题