Reloading / Displaying searchResultsTableView of UISearchDisplayController after search method iteration is finished

牧云@^-^@ 提交于 2019-12-04 11:46:27

I have same problem and I just solved it. I had exactly same problem, I wanted disable instant search and when I hit search button, the table didn't load but when I clicked cancel, it loaded up. And If I scroll on table view that didn't load correct result after search, it crashed due to index out of bound.

The thing you need to do is reload searchResultTableView not current tableview. After you filter out your data by search term, put

[self.searchDisplayController.searchResultsTableView reloadData]

to reload your search result, and it will shows up after you hit search button. Hope this help

I found that setting the searchBar.text causes searchDisplayController.searchResultsTableView be added to self.view, I solve it like this:

self.searchBar.text = @"xxxx";
[self.searchDisplayController.searchResultsTableView removeFromSuperview];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!