3
votes

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 display controller and UITableView. If reload data occurs on the tableView with the searchBar active. The issue still happens.

enter image description here

4
@titaniumdecoy...added an image. not sure if u seen this before?prostock
try to read how to implement them together, you're obviously missing a hint: edumobile.org/iphone/iphone-programming-tutorials/…Marek Sebera
@Marek..I reduced it to the bear minimum with interface builder...i just reload data after the search controller is active to cause the issueprostock
Tell me this. Why do you have two different tableviews ?Legolas
@legolas. the search display controller holds my search results. the normal table view holds a list of geolocation based results. it's standard for the the search controller to own it's own tableViewprostock

4 Answers

1
votes

I hope you know that you need two UITableViews 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

0
votes

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.

-1
votes

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.

-1
votes

You can use simple UISearchBar because without peer into your code, can not help you