I'm looking to duplicate how the Facebook Messenger app shows the UISearchBar. When you tap the leftBarButtonItem in the navigationBar, the UISearchBar appears/animates from the top of the screen down, and when you cancel, it simply disappears upwards where it originated from.
I used to have my UISearchBar as the default setup in my table view's header (in storyboard), but now I'm wanting to do what I stated above but I am not sure where to begin. My search displayer controller is still in my storyboard, but I have deleted the searchBar from the tableView controller in the storyboard.
I appreciate any help offered!
It seems like Facebook hides the navigation bar and displays the Search Bar and Search Display Controller on top. Try hiding the navigation bar with
[self.navigationController setNavigationBarHidden:YES animated:NO];
and presenting your Search Bar and Search Display as a childView of your tableView. (I assume you know how "Search Bar and Search Display Controller" object works)Another way would be avoiding UITableViewController and adding a UITableView inside a UIViewController and hide the Search Bar under the Navigation Bar so when you hide the Navigation Bar, the Search Bar is visible.
You can also set the UISearchBar as the UINavigationBar's
titleView
as described here.Check out Apple's UICatalog sample code. Basically just present your
UISearchController
modally and you get the dropdown animation for free.Omitting detail of my own project where I make the same thing it looks as follows:
Note: The general behavior of this construction is analogous to UISearchDisplayController, the only difference is that we use the same table to show all results and filtered result. Also we need artificial shadow view.
It was my initial code and its behavior coincides with FB People view controller. After your comment I wrote standard UISearchDisplayController embedding but after commented it out because it breaks desired UI. It is impossible to change its animation behavior.