Cocoa touch 没有即时搜索的UISearchDisplayController:如何控制TableView的暗显?
我使用Apple的示例引用实现了一个UISearchDisplayController。我的列表包含超过10000个元素,这使得过滤速度太慢,无法在用户输入的每个字符上执行过滤。我已经成功地将搜索限制为当用户使用以下代码单击搜索按钮时Cocoa touch 没有即时搜索的UISearchDisplayController:如何控制TableView的暗显?,cocoa-touch,uisearchdisplaycontroller,Cocoa Touch,Uisearchdisplaycontroller,我使用Apple的示例引用实现了一个UISearchDisplayController。我的列表包含超过10000个元素,这使得过滤速度太慢,无法在用户输入的每个字符上执行过滤。我已经成功地将搜索限制为当用户使用以下代码单击搜索按钮时 - (void)searchBarSearchButtonClicked:(UISearchBar*)searchBar { [self filterContentForSearchText:[self.searchDisplayController.se
- (void)searchBarSearchButtonClicked:(UISearchBar*)searchBar
{
[self filterContentForSearchText:[self.searchDisplayController.searchBar text]
scope:[self.searchDisplayController.searchBar selectedScopeButtonIndex]];
[self.searchDisplayController.searchResultsTableView reloadData];
}
- (BOOL)searchDisplayController:(UISearchDisplayController*)controller
shouldReloadTableForSearchString:(NSString*)searchString
{
return NO;
}
现在,我的问题是,一旦用户输入第一个字符,表视图的暗显就会消失,我希望它保持暗显,直到用户单击搜索按钮。(或取消搜索。)searchDisplayController是一个黑框,因此您无法控制它何时显示searchResultsTableView(在搜索栏中第一次按键时显示) 您可以在resultsTableView上显示半透明视图,以显示searchDisplayController提供的初始暗显效果,但searchResultsTableView仍将可见
- (BOOL)searchDisplayController:(UISearchDisplayController*)controller
shouldReloadTableForSearchString:(NSString*)searchString
{
// display a translucent view over the searchResultsTableView and
// make sure it's only created on first key press
return NO;
}
另一个选择是自己编写代码