Why doesn't my UISearchDisplayController fire the shouldReloadTableForSearchString method when I enter text in the search box?

I followed the Apple TableSearch example code but it doesn't work for me and I think I am doing things the way they did it. The method below should run whenever the user types something in the search box, but it never works for me, just in the sample app.

My header file has this implementation:

@interface ContactsTableVC : UITableViewController <UISearchDisplayDelegate, UISearchBarDelegate>{

      

I'm not sure what I'm missing or where else to look.

My NSLog is never called.

Thanks for the help!

    - (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString searchScope:(NSInteger)searchOption
{
    NSLog(@"The shouldreloadtableforsearchstring method has been called!");
    [self filterContentForSearchText:searchString];

    // Return YES to cause the search result table view to be reloaded.
    return YES;
}

      

+2


a source to share


2 answers


Dang I feel stupid. I looked at everything at least 100 times to make sure everything was going right, and as usual it was something small that I forgot. My TableViewController xib contained TWO SearchDisplayControllers in the Builder frontend somehow. It did not match the first one, which was not related to the search bar. I just had to remove that first SearchDisplayController and it started ...



Thanks @Jordan for the quick response. We really appreciate it!

0


a source


Have you added the UISearchDisplayDelegate delegate to the @interface ContactsTableVC.



0


a source







All Articles