我在一个包含UITableView
的UIViewcontroller
中使用UISearchController
,我在viewDidLoad
中实现:
self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
self.searchController.delegate = self;
self.searchController.searchResultsUpdater = self;
self.searchController.searchBar.delegate = self;
self.searchController.dimsBackgroundDuringPresentation = NO;
self.searchController.hidesNavigationBarDuringPresentation = NO;
self.definesPresentationContext = NO;
当我点击导航栏中的按钮时,我会执行以下操作:
self.tableView.contentOffset = CGPointMake(0, 0 - self.tableView.contentInset.top);
self.tableView.tableHeaderView = self.searchController.searchBar;
[self.searchController.searchBar becomeFirstResponder];
一切工作正常,但当我从UITableView
中的行推送一个UIViewController
时,UISearchBar
会停留在那里,并且还会显示在其他视图的内容上,当我推出一个视图时如何让它消失,并在返回查看UITableView
结果时再次显示?
谢谢
编辑:
这是didSelectRowAtIndexPath
方法的代码:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
DetailListController *detailList = [[DetailListController alloc] init];
[self.navigationController pushViewController:detailList animated:YES];
}
didSelectRowAtIndexPath:
的代码吗?在那里你是如何推出新的视图控制器的。 - Abhinav