Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UISearchBar Sample Code [closed]

Tags:

Implementing a searchbar can be tricky business and I'm struggling to make it work for my situation. Here's a collection of some of the sample code I've found for implementing a UISearchBar. Please share any others below you've come across below.

Apple's TableSearch code implements a contacts-like search of a simple tableview.

Beginning iPhone Dev Book's Sections sample code implements a searchBar on a sectioned tableview. Data is pulled from a plist.

iPhone Developers Cookbook Chapter 8, 10a SearchBar example searches a table of color names. Selection of a color name changes the tint of the search bar. Also see their Chapter 9 01a-Finding People app.

iPhoneSDK's source code TableViewPart6 searches a table of country names with 2 sections for countries visited and those to visit.

Stanford's iPhone app programming class's 08-MyTableView sample filters a simple list of names.

like image 911
Jonah Avatar asked Aug 19 '09 22:08

Jonah


1 Answers

WAIT: Apple has implemented the Search Display Controller in the iPhone SDK 3.0. You can drag that to the header of your tableView, or programmatically set that as headerView. You only have to set a few simple parameters (like the dataSource, which is just an UITableViewDatasource and a viewController, where the results have to been showed in). This gives you exactly the same look as the contacts-application and all other Apple-applications (you can also set 'scopes' like the Mail-app)

like image 89
cutsoy Avatar answered Oct 02 '22 22:10

cutsoy