0

I am attempting to use a UISearchDisplayController and failing. I have a menu view that happens to contain a search bar. I ONLY want a table view when the user taps into the search bar, I do not want the "filtered" and "unfiltered" state type setup.

A UISearchDisplayController apparently comes with a table view but is there anything I need to do? I implemented your basic table view data source methods, but they are not getting called. Essentially I am getting zero action from the search display controller. I am using a nib file, so how can I actually get this to work? I read over 40 forum posts that yielded no useful information. Please help me :)

(I have no code to show, as I don't even know where to start)

The effect I want is to have a search bar about 1/3 down the screen, and when the user taps into it, it animates into the navigation bar, and does its thing.

Thanks!

DBoyer
  • 3,062
  • 4
  • 22
  • 32
  • Are you implementing the table view data source and delegate methods for the `self.searchDisplayController.searchResultsTableView`? – andrewbuilder Aug 08 '14 at 03:44
  • Also, not knowing whether you are using Storyboard or creating programmatically, read this [answer](http://stackoverflow.com/questions/23410353/search-bar-and-search-display-controller-in-table-view/23452670#23452670) I wrote about programmatically creating `UISearchDisplayController` in `UITableViewController`. It does not assist with your search bar placement or animation but may provide a good checklist for implementation of your `UISearchDisplayController`. – andrewbuilder Aug 08 '14 at 03:50

1 Answers1

0

As far as I know you can't do this with UISearchDisplayController. In general, it has been broken for quite some time in many scenarios and I would not recommend using it at all unfortunately.

The iOS 8 replacement for this is UISearchController which is meant to solve the issues that have been plaguing UISearchDisplayController.

There is a WWDC 2014 session outlining this controller and related ones (presentation controllers). It also goes over the many limitations and issues with UISearchDisplayController. You can find it here. It is session 228: A Look Inside Presentation Controllers.

Until iOS 8 is out of beta and the APIs are finalized though, you may be better off rolling your own solution.

Dima
  • 23,484
  • 6
  • 56
  • 83
  • unfortunately, I will be needing this done before iOS8 is launched. Thank you for the insight though :). Do you have any idea how I can animate a search bar "into" the navigation bar? I would really like that effect. – DBoyer Aug 05 '14 at 23:36
  • Do you need to explicitly set the table view of a search display controller? – DBoyer Aug 05 '14 at 23:37
  • For starters you would want to have the bar style of the search bar as `UIBarPositionTopAttached` so that it is the same size as the navigation bar (stretching to the status bar). You could animate the search bar to the top of the view while also animating away the navigation bar with something like `[self.navigationController setNavigationBarHidden:YES animated:YES];` – Dima Aug 05 '14 at 23:44