我有一个 UITableView
实现了 searchDisplayController
。我有
tableView.backgroundColor = [UIColor clearColor];
和
self.searchDisplayController.searchResultsTableview.backgroundColor = [UIColor clearColor];
当我在搜索字段中输入文本时,搜索结果显示正常,但由于结果表的背景是透明的,我看到了我的 tableview
和 tableview
显示搜索结果表。我想在 searchField 开始编辑时隐藏 tableView
。我试过了
-(BOOL)searchDisplayController:(UISearchDisplayController *)controller
shouldReloadTableForSearchString:(NSString *)searchString
{
[tableView setHidden:YES];
[self filterContentForSearchText:searchString
scope:[[self.searchDisplayController.searchBar scopeButtonTitles]
objectAtIndex:[self.searchDisplayController.searchBar
selectedScopeButtonIndex]]];
return YES;
}
但是它用 tableView 隐藏了 searchBar。如何解决?
最佳答案
首先,我知道您在 UITableView
上添加了 searchDisplayController
。
请删除它并在您的 View Controller 上添加您的UISearchDisplayController
而不是UITableView
,因为如果您隐藏UITableView
然后 UISearchDisplayController
也隐藏了,因为你在 UITableView
上添加了 UISearchDisplayController。
谢谢 :)
关于iphone - 显示搜索结果 TableView 时隐藏 UITableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14807406/