I have an UISearchBar and UISearchDisplayController implemented correctly to filter the cells in a UITableView.
Sometimes it works fine and filters the cells according to the entered search term. But sometimes - without changing a line of code - it doesn't filter and shows all cells.
In the tableView delegates I notice that the IF
statement below would be FALSE
and thus display all contacts as search results in searchResultsTableView
.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (tableView == self.searchDisplayController.searchResultsTableView)
{
return [_searchResultContacts count];
}
else
{
return [_allContacts count];
}
}
Why is that?
(Don't answer, I will post the answer below!)