0

I have created a UITableViewViewController with a UISearchDisplayController. When i search in the searchbar the values will show in en extra tableview.

I set both background on clearColor, therefore I can see that both tableviews have data.

How can i handle that there will be shown only the searched data when using the searchbar and after that the normal data will show?

That's the methods I use for the UISearchDisplayController:

- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
{
    self.filteredList = [SearchHelper getSearchedItemsAsArray:[self.arrayWithCompanies mutableCopy] searchWord:searchString scope:[[self.searchDisplayController.searchBar scopeButtonTitles] objectAtIndex:[self.searchDisplayController.searchBar selectedScopeButtonIndex]]];
    return YES;
}

-(BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchScope:(NSInteger)searchOption
{
    [SearchHelper getSearchedItemsAsArray:[self.arrayWithCompanies mutableCopy] searchWord:self.searchDisplayController.searchBar.text scope:[[self.searchDisplayController.searchBar scopeButtonTitles] objectAtIndex:searchOption]];
    return YES;
}

Thanks for help and tips

Logi24
  • 528
  • 6
  • 17

1 Answers1

1

There are two possibilities

1) Use searchbar control only instead of UISearchDisplayController and fill data in tableview as per your need !!

2) Hide the actual tableview while searching and data will be displayed in UISearchDisplayController tableview.

iDeveloper
  • 498
  • 4
  • 9
  • The first option helped. BY the second option it will hide all and you see nothing. But it works now with option one Thanks – Logi24 Jan 22 '14 at 13:31
  • You are Welcome... and in second option what I was suggesting is to hide the actual tableview and UISearchDisplayController also have its own tableview in which data are populated.so you will be able to see your data. – iDeveloper Jan 23 '14 at 04:22
  • ah ok. Mhh that's an option but i prefere your first option, becuase to tableviews and so on is a bit to excessive for this solution. Then you have double code and na your first option works for me. Thank you, even so for your explanation. Thanks – Logi24 Jan 23 '14 at 13:48