开发者

Why won't my UISearchDisplayController fire the shouldReloadTableForSearchString method when I entered text into the search field?

I've been following Apple's TableSearch code example, but it's not working for me and I think I'm doing everything the same way they did it. The method below should be fired whenever the user types anything into the search box, but it never gets fired for me, just on 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 never gets called.

Thanks for the help!

    - (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldRe开发者_如何学CloadTableForSearchString:(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;
}


Have you added the delegate UISearchDisplayDelegate in the @interface ContactsTableVC file.


Dang I feel dumb. I looked at everything at least 100 times to make sure I was going it right and as usually happens, it was something small that I overlooked. My TableViewController xib somehow had TWO SearchDisplayControllers in it in Interface Builder. It was defaulting to the first one, which was not linked to the search bar. I just had to delete that first SearchDisplayController and everything started working...

Thanks @Jordan for the quick response. Much appreciated!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜