You need to understand that when you have a UISearchDisplayController and the search bar is active, the UITableView argument passed to your UITableView data source and the delegation methods are NOT really your tableView object, but the tableView is managed by the UISearchDisplayController designed to display live results Search (for example, results filtered from your main data source, for example).
You can easily find this in the code, and then return the corresponding result from the delegation / data source method, depending on which tableView object is requesting.
For instance:
- (NSInteger) tableView: (UITableView *) tv numberOfRowsInSection: (NSInteger) section
{
if (tv == self.searchDisplayController.searchResultsTableView) {
// return the number of rows in section for the visible search results.
// return a non-zero value to suppress "No results"
} else {
// return the number of rows in section for your main data source
}
}
The fact is that your data sources and delegation methods serve tables two , and you can (and should) check which table is requesting data or delegation.
By the way, "No results" (I think) is provided by the background image that the UISearchDisplayController displays when the delegate says that there are no rows ... You do not see a table of 2 rows, the first space and the second with the text "No results". At least this is what I think is going on there.
source share