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])
问题是,当单击取消按钮时,标题和索引起初保持隐藏状态。我尝试(在searchBarCancelButtonClicked
中)调用[self.tableView reloadData]
,但不起作用。
我的viewWillAppear
中有一个[self.tableView reloadData]
,这在某种程度上有帮助:如果我选择一行,将另一个视图推到堆栈上,然后返回到此表,则标题和索引会按需显示。
我可能做错了什么?