UISearchDisplayController without instant search: How do I control the dimming of the TableView?
I have implemented a UISearchDisplayController using Apple's TableSearch sample reference. My list contains just over 10.000 elements, and this makes the filtering too slow to execute it on every character that the user enters. I've managed to restrict to search to when the user click on the search button with the following code.
- (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;
}
Now, my problem is, that as soon as the user enters the first character the dimming of the table view disappears, and I would like to keep it dimmed until the user clicks the Search buton. (Or cancels the search.)
The searchDisplayController is a black box so you don't have any control over when it displays the searchResultsTableView (which in on first key press in the searchBar).
You could display a translucent view over the resultsTableView to give the appearance of the initial dimming provided by the searchDisplayController but the searchResultsTableView will still be visible.
- (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;
}
The other option is to code your own.
精彩评论