UISearchController with nil searchResultsController

I am using UISearchController with a UITableView and using the same table view on my base view controller to display search results (by doing this without specifying a separate search results controller as searchController = UISearchController(searchResultsController: nil)).

However, even though the searchResultsController parameter is zero, an empty transparent one _UISearchControllerViewis still displayed on top of my view controller when the search is active.

Is there a way to prevent this and keep my view controller at the top of the hiearchy view controller when searching?

Thank.

+4
source share
3 answers

, dimsBackgroundDuringPresentation false

searchController.dimsBackgroundDuringPresentation = false
+1

UISearchController , . , searchResultsController. , , .

searchController.dimsBackgroundDuringPresentation = false
0

Hi folks, please try this.

-(void) searchBar: (UISearchBar *) searchBar textDidChange:(NSString *)     searchText{
NSMutableArray *sortedData = [[NSMutableArray alloc] init];

    if ([searchText isEqualToString:@""]) {
        _localArray = _mainArray; // you must take a local array
    }
    else{
       //show your sorted data
    }

}

- (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar{
searchBar.text = nil;
[searchBar resignFirstResponder];
}
-(void)searchBarSearchButtonClicked:(UISearchBar *)searchBar{
[searchBar resignFirstResponder];
[self.view endEditing:YES];
}
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar{
[searchBar resignFirstResponder];
[self.view endEditing:YES];
}
-1
source

All Articles