I have a table view, with a long list of strings. There are headers for each section, an index along the right hand side, and a search button. This has been implemented programmatically, using a UISearchDisplayController, (i.e. not in IB).
When the search button is activated, I hide the headers (in titleForHeaderInSection
), and hide the index (in sectionIndexTitlesForTableView
), by asking
if ([self.searchDisplayController isActive])
The problem is, when the cancel button is clicked, the headers and index remain hidden, at first. I tried (in searchBarCancelButtonClicked
) to call [self.tableView reloadData]
, but that doesn't work.
I have a [self.tableView reloadData]
in my viewWillAppear
, which helps in one way: if I select a row, push another view onto the stack, and then go back to this table, the headers and index are there as wanted.
What might I be doing wrong?
I've found that sometimes, when [tableView reloadData] doesn't work, doing this will:
For whatever reason, sometimes the table view gets into such a state that it must wait until the next iteration through the run loop before the reload will be effective.