开发者

UISearchDisplayController cancel button not refreshing headers and index

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])

T开发者_运维知识库he 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:

[tableView performSelector:@selector(reloadData) withObject:nil afterDelay:0];

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜