I have a UITableViewController
, in which I added a UISearchBar as the tableHeaderView
using Interface Builder. Then I added a UISearchDisplayController
in the nib, and set up all the connections (delegate
, searchResultsDelegate
, searchContentsController
, searchResultsDataSource
, all connected to the UITableViewController
).
I then implemented all the delegate and data source methods in my code.
It works like a charm, except for a weird bug: sometimes the search results table view won't scroll, and I can see the flash indicator of the main table view behind it. I NSLog'd the searchResultsTableView
and apparently it's a subview of the main tableview, and I guess that's the reason behind the touch problems I described earlier.
What's my mistake? Is it possible to use a UITableViewController
with UISearchDisplayController
at all? If so, how do I set up it in such a way that the results table view doesn't get added as a subview of my main table view?
Update: I found this sample which uses UISearchDisplayController
with UITableViewController
and apparently the search table view gets added to the main table view in there as well. So now I don't think that's my problem.
The thing is that I can't find any substantial difference between what I'm doing and what that sample is doing. I'm just adding an UISearchBar
as a UITableView
header in a UITableViewController
and adding a UISearchDisplayController
to it... It's like iOS is confused between the main table and the search table when I try to scroll. Do you have any ideas?
Update: Added a 200 rep bounty. Please answer only if you know what you're talking about.
It was an extra self.tableView.scrollEnabled = YES
which was called as soon as the search data request was finished. Hope it helps anyone with the same problem in the future.
A search display controller manages display of a search bar and a table view that displays the results of a search of data managed by another view controller.
Here the searchDisplaycontroller combines the searchbar and tabelview which showing the result data in the tableview so it won't required separate tableview.
While when you using UISerarchBar then it need to have atleast one UITableView, which can show results in the view. And here you can see the result without even adding the SearchDisplayController to view.
I think you might want to try adding a UISearchDisplayController IBOutlet to your class and connect that to your SearchdDisplayController in the nib file. I am amusing that that searchdisplay controller in your nib automatically connected it self to the default serachdisaplaycontreoller outlet in the inspector.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With