と をUIViewController含むストーリーボードにセットアップがtableviewありますUISearchDisplayController。
self.tableview (ストーリーボードのメイン テーブルビューに接続されている) からカスタム プロトタイプ セルを使用しようとしています。self.tableviewビューをロードしたときに少なくとも 1 つのセルが返された場合は正常に動作しますがself.tableview、(データがないため) セルをロードせず、UISearchBarand 検索をロードすると、cellForRowAtIndexPath:メソッドがクラッシュします。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
CustomSearchCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"CustomSearchCell" forIndexPath:indexPath];
[self configureCell:cell atIndexPath:indexPath];
return cell;
}
-(void)configureCell:(CustomSearchCell *)cell atIndexPath:(NSIndexPath *)indexPath {
User *user = [self.fetchedResultsController objectAtIndexPath:indexPath];
cell.nameLabel.text = user.username;
}
エラー:
*** Assertion failure in -[UITableViewRowData rectForRow:inSection:heightCanBeGuessed:]
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'request for rect at invalid index path (<NSIndexPath: 0x9ef3d00> {length = 2, path = 0 - 0})
上記のメソッドが呼び出された時点で、私の fetchedResultsController にはデータ (1 セクション、2 行) があるようです。ライン上でクラッシュしdequeueReusableCellWithIdentifierます。
ポインタ/アイデアはありますか?からプロトタイプセルをデキューする必要がありますself.tableviewが、作成されたものがなかったself.tableviewので、これが原因でしょうか?