Has anyone successfully reloaded a tableView, while the tableView is in the background of a searchbar display controller? See photo with what happens.
I have a UITableViewController with a search display controller. When I call reloadData on UITableViewController's tableview while the search display controller's table view is displayed, the section view header from the UITableViewController gets drawn onto the search display controller's view.
Here is a snapshot that shows the section title view ontop of the search display controller view:
Update: I simplified the code to a simple search displa开发者_JAVA百科y controller and UITableView. If reload data occurs on the tableView with the searchBar active. The issue still happens.
I hope you know that you need two UITableView
s for a search bar to work. When the search is active, you should manage and display the search results table, otherwise your original one.
From Apple's documentation: The results are displayed in a table view that’s created by the search display controller.
Therefore, you should not reload the original UITableView
but rather make sure your datasource
for the search results table is correct.
UISearchDisplayController
has a property called searchResultsTableView
which you will not have to specifically reload with reloadData
. Rather, it will be updated through the methods in the UISearchDisplayDelegate
protocol, such as searchDisplayController:shouldReloadTableForSearchString:
.
Cheers,
Sascha
I had this exact problem. If your case is like mine, the cause is [self.tableView reloadData] redrawing the self.tableView header title even when self.tableView is below the searchResultsTableView.
[self.tableView reloadData] was being called 1) when I was fetching from my table view data source and 2) in the setter for my fetchedResultsController.
Also, if your tableView controller is a delegate of fetchedResultsController, it receives updates whenever your Core Data managed document is changed. This was also causing the header to be redrawn.
Solution: I removed [self.tableView reloadData] when populating search results. Also, I removed the tableview controller as a delegate of fetchedResultsController.
Using NSLog try to check when is your section view header from UITableView gets drawn exactly. May be you can then figure out why this is happening. Then try using scrollEnabled=NO, as you are thinking.
You can use simple UISearchBar because without peer into your code, can not help you
精彩评论