views:

38

answers:

1

Hi, I'm trying to set up a UISearchBarDelegate

My first attempt was to clear the search results when searchBarShouldEndEditing: was called, but I discovered that this gets called when scrolling through the search results, which is not a time to be getting rid of the array of them.

My next attempt is searchBarCancelButtonClicked: - but this doesn't get called if the search bar is empty and they tap the space below (where a greyed out view of the table view is showing).

So how do you know when to switch from returning search results cells to returning regular table view cells?

Thanks for any help with this.

A: 

You can check which table view is requesting the cells. searchDisplayController.resultsTableView is what requests your search results cells. Just check for this in cellForRowAtIndexPath

Joshua Weinberg