sir*_*333 0 iphone uinavigationcontroller rightbarbuttonitem uinavigationitem
我正在尝试向UINavigationController的导航栏添加2个按钮:
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];
Run Code Online (Sandbox Code Playgroud)
}
谁知道为什么这不起作用?(对于它的价值,我正在使用Xcode 4.2,使用Storyboard ......)
你设置rightBarButtonItem filterButton
,但不应该是searchButton
?
// 2nd. button - this one does not show up:
UIBarButtonItem *searchButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemSearch
target:self
action:@selector(goSearching:)];
// Here I think you wanna add the searchButton and not the filterButton..
self.navigationItem.rightBarButtonItem = searchButton;
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7567 次 |
最近记录: |