uitableview reloadData issue

可紊 提交于 2019-12-04 18:16:59

UISearchDisplayController has its own tableView property called searchResultsTableView. If you are using a searchDisplayController, try using:

[searchDisplayController.searchResultsTableView reloadData];

The behavior you are describing (with the new data not being shown until scrolling) is exactly what I would expect to happen if you did not call reloadData on the table view. I would set a few breakpoints and make sure that the reloadData is really being called, on the right UITableView, and that cellForRowAtIndexPath is called, as a result of the reloadData.

One guess is that your self.tableView IBOutlet is not wired up, and that self.tableView is NULL. It is possible that the tableview Delegate and Datasource are wired up, but not the tableView itself.

[self.searchDisplayController.searchResultsTableView reloadData];

viewDidLoad only gets called once when the view controller is loaded. You probably want to update the table every time the view gets displayed (when you switch tabs for example), put your reloadData call in viewWillAppear instead.

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