I have a UITableView with a searchDisplayController implemented. I have
tableView.backgroundColor = [UIColor clearColor];
and
self.searchDisplayController.searchResultsTableview.backgroundColor = [UIColor clearColor];
When I enter text in the search field, the search results are displaying fine, but as the background of the resultant table is transparent, I am seeing my tableview and on the tableview the search result table is displayed. I want to hide the tableView when the searchField began editing. I have tried
-(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;
}
But it hides the searchBar with the tableView. How to fix it?
First i know that you add
searchDisplayControlleronUITableView.Remove it Please and Add your
UISearchDisplayControlleron your View Controller not onUITableView, beacuse if you hideUITableViewthenUISearchDisplayControlleralso hide because you added UISearchDisplayController onUITableView.Thanks 🙂