Question

I have a UISearchDisplayController that is properly hooked up in Interface Builder.

delegate = Files Owner
searchBar = Search Bar
searchContentsController = Files Owner
searchResultsDataSource = Files Owner
searchResultsDelegate = Files Owner

When my UITableView calls numberoOfRowsInSection: the correct number is returned.

However, my cells in cellForRowAtIndexPath: don't even reach:

- (UITableViewCell *)tableView:(UITableView *)tblView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

 if (tblView == searchController.searchResultsTableView){
  NSLog(@"search will go here");
  UITableViewCell* cell = [self provideSearchQueryCells:tblView identifer:@"searchQueryCell"];
  STSymbol *aSymbol = [self.searchQueryResults objectAtIndex:indexPath.row];

  cell.textLabel.text = aSymbol.symbol;
  cell.detailTextLabel.text = aSymbol.symbol_title;

  return cell;
 }
 else { ... }

It always goes to the else condition.

I am not exactly sure why.

Was it helpful?

Solution

I needed to create an instance of a UISearchDisplayController instead of using self.searchDisplayController.

OTHER TIPS

use the following. It should work.

 if ([tblView isEqual:[searchController searchResultsTableView]]) {
...
}

you should also make sure the search result row count is correct as in :

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

    if ([tblView isEqual:[searchController searchResultsTableView]]) {
        return [self.searchResults count];
    }
...
}

This is a guess from this close in on the code, but are we looking at the search display controller itself? Maybe your self.searchDisplayController.searchResultsTableView should just be self.searchResultsTableView.

I can't be sure without knowing your delegates.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top