This is pretty tricky. _dimmingView is private to searchDisplayController, and it goes above all subzones. What you can do is cover it with your custom view every time it appears ([searchString length] == 0 and DidBeginSearch)
(tempView frame set for UISearchBar placed in tableViewHeader)
- (void)viewDidLoad { tempView = [[UIView alloc] initWith...]; // tempView setup ... } - (void)searchDisplayControllerDidBeginSearch:(UISearchDisplayController *)controller { [tempView setFrame:CGRectMake(0, self.searchDisplayController.searchBar.frame.size.height, 320, self.searchDisplayController.searchResultsTableView.frame.size.height)]; [self.searchDisplayController.searchContentsController.view addSubview:tempView]; ... } - (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString { if ([searchString length] == 0) [self.searchDisplayController.searchContentsController.view addSubview:tempView]; else [tempView removeFromSuperview]; ... } - (void)searchDisplayControllerDidEndSearch:(UISearchDisplayController *)controller { if (tempView && tempView.superview) [tempView removeFromSuperview]; ... }
Notes. I tried to create a new instance on DidBeginSearch and release it on DidEndSearch, and it worked only for the first call! Weird ...
Hope this helps
source share