Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 25th, 2012  |  syntax: None  |  size: 1.52 KB  |  hits: 31  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. cellForRowAtIndexPath not called from UISearchDisplayController delegates
  2. table = [[UITableView alloc] initWithFrame:CGRectMake(0.0f, 80.0f, 480.0f, 260.0f)];
  3.     table.delegate = self;
  4.     table.dataSource = self;
  5.     [[[CCDirector sharedDirector] openGLView] addSubview:table];
  6.  
  7.     UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectZero];
  8.     [searchBar sizeToFit];
  9.     searchBar.delegate = self;
  10.     searchBar.placeholder = @"Search";
  11.     table.tableHeaderView = searchBar;
  12.  
  13.     UISearchDisplayController *searchDC = [[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self];
  14.     searchDC.delegate = self;
  15.     searchDC.searchResultsDataSource = self;
  16.     searchDC.searchResultsDelegate = self;
  17.  
  18. //        [searchBar release];
  19. //        [searchDC release];
  20.        
  21. - (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope
  22. {
  23.     // Do filtering and add to the search array
  24. }
  25.  
  26. - (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
  27. {
  28.     [self filterContentForSearchText:searchString scope:[[controller.searchBar scopeButtonTitles] objectAtIndex:[controller.searchBar selectedScopeButtonIndex]]];
  29.  
  30.     return YES;
  31. }
  32.  
  33. - (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchScope:(NSInteger)searchOption
  34. {
  35.     [self filterContentForSearchText:[controller.searchBar text] scope:[[controller.searchBar scopeButtonTitles] objectAtIndex:searchOption]];
  36.  
  37.     return YES;
  38. }