开发者

UISearchDisplayController is not displaying any cells

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 ide开发者_Go百科ntifer:@"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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜