Reloading UITableView behind UISearchDisplayController

Viewed 6022

I've run into this really strange phenomenon that I can't quite figure out. I have a UITableViewController that manages a UITableView. Pretty simple. I also have a UISearchDisplayController for searching the contents of the table view. The searching functionality will be able to delete items of the content displayed by the table view. So if the user chooses to delete one of the items they found while searching, I want to not only reload the UISearchDisplayController's table view but also the UITableViewController's table view. When I do that, the sections of the regular table view pop out and display above the UISearchDisplayController. It's really quite strange. I think the best way to explain it is with an image:

http://img46.imageshack.us/img46/2818/screenshot20100905at140.png

If any of you know what could possibly be causing this problem or know a workaround, that would be fantastic.

9 Answers

Our solution is to do the following. It has only been tested in iOS 7:

  1. In viewForHeaderInSection, return nil if self.searchDisplayController.active is YES
  2. In didHideSearchResultsTableView, call [self.tableView reloadData] to reload the headers when the search table disappears

Fixed it..

Add the following lines in viewDidLoad

searchDisplayController.searchResultsTableView.delegate = self;
searchDisplayController.searchResultsTableView.dataSource = self;

That fixed it for me...

Related