1

私は自分の iPhone プロジェクトで UIStoryboard を使用しており、UITableViewController のサブクラスであり、UISearchDisplayController を持つコントローラーを持っています。

tableView:cellForRowAtIndexPath で、次を使用してセルを取得しています。

MyCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];

CellIdentifier は、プロトタイプ セルの識別子です。テーブルの行を表示するときは問題なく動作しますが、検索バーを編集すると、検索結果を表示しようとするビューにセルがありません。

4

1 に答える 1

3

これを追加:

if (cell == nil) {
    cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
}

そして、私のように、テーブル セルの行の rowHeight を変更した場合は、このメソッドも実装する必要があります。

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return self.tableView.rowHeight;
}
于 2011-12-29T02:17:53.177 に答える