3

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 implement this?

Maarten Bodewes
  • 84,836
  • 13
  • 136
  • 244
Ajit
  • 101
  • 1
  • 2
  • 8

4 Answers4

3

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.

John Parker
  • 53,316
  • 11
  • 128
  • 128
3

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

Community
  • 1
  • 1
Waqas Raja
  • 10,542
  • 4
  • 32
  • 38
0

You will have to create two different tables

  1. One for showing all values.
  2. 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
Bug
  • 2,550
  • 2
  • 19
  • 36
Baddu
  • 290
  • 2
  • 11