UISearchDisplayController search results table has wrong content size when search bar in different view controller

Originator:luke
Number:rdar://15251896 Date Originated:17 Oct 2013
Status:Open Resolved:
Product:iOS SDK Product Version:7.0
Classification:UI/Usability Reproducible:Always
 
Summary:
I have a custom app layout that uses view containment and container views. Within this layout, there is a search bar (owned by one view controller and displayed within it's view) that is managed by a UISearchDisplayController, but the search display controller's content view is a UITableVIewController in a different container view.

With this arrangement, when the search is active, the searchResultsTableView does not have it's contentInset set correctly when the keyboard is dismissed and there are also issues where touches are passed through to the original table view causing it to begin scrolling (moving the embedded search results table view with it).

I've only really seen this on iPad - it's not really an issue on iPhone where this kind of custom layout isn't used, and the keyboard cannot be dismissed independently of the search anyway.

Steps to Reproduce:
1. Create a custom container view controller, with a container view.
2. Create a UITableViewController sub-class with some data and initialise it in viewDidLoad of the container view controller.
3. Create a search bar and a search display controller, passing in the UITableViewController subclass to the search display controller as it's content view controller. Pass the search display controller into the TVC subclass using a property.
4. Add the search bar to the root view of the container view controller, such that the search bar and the view containing the UITableViewController are siblings.
5. Add the TVC to the container view using the view containment APIs.
6. In the TVC viewDidLoad, wire up the search display controller's data source/search delegate as appropriate to implement the search.
7. Start searching. Dismiss the keyboard. Note that there is a gap at the bottom of the search results table view where the keyboard was.
8. Drag within the empty area and notice that you are now scrolling the original table view and moving the search results table view with it.

Expected Results:
I'd expect this to work as if the search bar and search results table view were part of the same view controller hierarchy.

Regression:
This worked on iOS6.

Notes:
A sample app has been provided that demonstrates this issue.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!