Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS: Adding UISearchbar with filter Options in a tableview

I am relatively new to iOS (coming from android background), and I would like to know how to implement and have a searchbar like in these two pictures http://i.stack.imgur.com/rQKE5.jpg and here(linkedin) http://i.stack.imgur.com/BnIG2.png . Would like to know how to make make the filters/options appear dynamicly when users clicks on search field and affect the results shown in the uitable. Example on linkedin 4 filters appear when user clicks on search. I have search on the net but I didn't manage to find persistent results. Again, what I want to know is how to show those options/filters when user click on searchbar

Any help is apreaciated, code or sample/ existing projects would be very useful.

Thank you all in advanced

like image 523
user3346173 Avatar asked Apr 16 '14 14:04

user3346173


1 Answers

UIKit comes with a dedicated built-in solution for searching in conjunction with a UITableViewController, called UISearchDisplayController. It provides everything (albeit without much customization), including the search bar view, an optional scope bar for filtering, and transitions.

Reference: https://developer.apple.com/library/ios/documentation/uikit/reference/UISearchDisplayController_Class/Reference/Reference.html

Edit:

Here is a tutorial: http://www.appcoda.com/search-bar-tutorial-ios7/

And here is another one that includes a scope bar: http://www.raywenderlich.com/16873/how-to-add-search-into-a-table-view

Edit: All of this is obsolete now

iOS8 introduces a new class UISearchController to make this much cleaner. See http://useyourloaf.com/blog/2015/02/16/updating-to-the-ios-8-search-controller.html

like image 167
Clafou Avatar answered Nov 11 '22 14:11

Clafou