How to implement search bar in iPhone? [closed]
I am trying to implement a tab bar application in which a tab is provided with Search bar.
When I click on the Search button after entering some data into the search field, I should get a tableview
displaying the search results. The tableview
should be added as a subview.
How should I开发者_Python百科 implement this?
UISearchBar is a control in toolbox, you need to implement it, and implement search button press event to add tableview as a subview.
you can consult with the similar thread here
UISearchBar Sample Code
You need to take a look at Apple's UISearchDisplayController class reference documentation - this covers precisely what you're attempting to do and contains a link to a sample project (see the "Related sample code" section at the top) if you require some example code to look at.
Here you go: http://ved-dimensions.blogspot.com/2009/02/iphone-development-adding-search-bar-in.html
You will have to create two different tables
- One for showing all values.
- Second For showing searched result.
and implement these two delegates of UISearchBarDelegate,UISearchDisplayDelegate
-(BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
-(BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchScope:(NSInteger)searchOption
精彩评论