我正在尝试将 2 个按钮添加到 UINavigationController 的导航栏:
1)左侧的标准“后退”按钮 - 有效,并且
2)右侧的“搜索”按钮 - 不显示。
这是代码:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// 1st button - this shows up correctly:
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] init];
backButton.title = @"MAIN";
self.navigationItem.backBarButtonItem = backButton;
// 2nd. button - this one does not show up:
UIBarButtonItem *searchButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemSearch
target:self
action:@selector(goSearching:)];
self.navigationItem.rightBarButtonItem = searchButton;
itemsByTitleVC *itemsView = [[itemsByTitleVC alloc] initWithNibName:@"itemsByTitleVC" bundle:nil];
[self.navigationController pushViewController:itemsView animated:YES];
}
有人知道为什么这不起作用吗?(对于它的价值,我使用的是 Xcode 4.2,带有 Storyboard ......)