2

Interface Builder に適切に接続された UISearchDisplayController があります。

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

UITableView を呼び出すとnumberoOfRowsInSection:、正しい番号が返されます。

しかし、私の細胞はcellForRowAtIndexPath:届かない:

- (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 { ... }

それは常にelse条件になります。

正確な理由はわかりません。

4

3 に答える 3

1

self.searchDisplayController を使用する代わりに、UISearchDisplayController のインスタンスを作成する必要がありました。

于 2010-08-13T15:00:09.623 に答える
1

以下を使用します。それはうまくいくはずです。

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

次のように、検索結果の行数が正しいことも確認する必要があります。

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

    if ([tblView isEqual:[searchController searchResultsTableView]]) {
        return [self.searchResults count];
    }
...
}
于 2012-03-22T07:14:17.247 に答える
0

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.

于 2010-08-13T00:53:07.153 に答える