I have a UISearchController and a UITableView. Code in viewDidLoad:
self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil]; self.searchController.searchResultsUpdater = self; self.searchController.dimsBackgroundDuringPresentation = YES; [self.searchController.searchBar sizeToFit]; self.searchController.searchBar.delegate = self; self.searchController.delegate = self; self.tableView.tableHeaderView = self.searchController.searchBar; self.tableView.userInteractionEnabled = YES;
I want the gray view to appear whenever I click on the search bar, and when I start typing, the gray view disappears and displays the tableView so that I can click on cells. That is, a gray view appears only when the search bar is empty (like the default search behavior in Mail and Contacts Apps). I tried to install
self.searchController.dimsBackgroundDuringPresentation
in the delegate method based on searchBar.text
-(void )searchBarTextDidBeginEditing:(UISearchBar *)searchBar
but that will not work. Any ideas?
Thanks,
ios objective-c uisearchbar uisearchcontroller
Missa
source share