Search code examples
controlleruisearchbaruipopovercontrollerpopoversearchdisplaycontroller

Dismiss Popover from SearchDisplayController


I programmed a SearchBar but no ot in the interface builder b< dragging the search to the tableView. The SearchResult was shown in an other TabelView. The search works great. But every time I search it shows me this SearchResult Popover. Can I delete this Popover?

[SetShowsSearchResultsButton self.searchDisplayController.searchBar: NO]; It also does not work

here is some code

- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
{
    [appDelegate.searchSource removeAllObjects];
    if (0  == [searchString length]) {
        NSLog(@"LEER");
        appDelegate.gefunden=NO;
        [appDelegate.rootViewController.tableView.tableView reloadData];
        [SearchBar1 resignFirstResponder];
    }
    for (NSArray *myPoi in appDelegate.poiList)
    {
        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(SELF contains[c] %@)", searchString];
        BOOL resultName = [predicate evaluateWithObject:[myPoi valueForKey:@"name"]];
        if (resultName) {
            appDelegate.gefunden = YES;
            [appDelegate.searchSource addObject:myPoi];
            [appDelegate.rootViewController.tableView.tableView reloadData];
            [self.searchDisplayController setActive:NO animated:YES];
            [self.SearchBar1 becomeFirstResponder];
        }
    }
    return YES;
}

and in viewdidload

self.searchDisplayController.searchResultsDataSource = appDelegate.rootViewController.tableView.tableView.dataSource;

Thanks


Solution

  • In IB try to set the searchResultsDelegate, searchResultsDataSource, searchContentsController values of your SearchDisplayController to Files Owner und put your code from

    - (BOOL)searchDisplayController:(UISearchDisplayController*)controller shouldReloadTableForSearchString:(NSString*)searchString
    

    to

    - (void)searchBar:(UISearchBar*)searchBar textDidChange:(NSString*)searchText
    

    That should do the trick.