iOS: Adding UISearchbar with filter Options in a tableview

假装没事ソ 提交于 2019-12-06 00:34:53

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/23112457/ios-adding-uisearchbar-with-filter-options-in-a-tableview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!