在导航控制器上显示工具栏按钮
嗨,我知道我错过了一些东西,因为它在网络上看起来很容易。 我正在向工具栏添加按钮,
工具栏正在显示。但没有任何按钮。
这是我的代码:
- (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];
}
谢谢您的帮助
hi i know i'm missing something because it seems pretty easy all over the web.
I'm adding buttons to my toolbar,
the toolbar is showing. but without any buttons.
this is my code :
- (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];
}
Thank you for your help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过通过以下方式设置项目:
注意: 请务必在视图控制器上设置此项,不要直接在
UIToolbar
实例上设置。Have you tried setting the items via:
Note: Be sure to set this on your view controller, do not set it on the
UIToolbar
instance directly.