我有一個UIViewController
安裝在一個tableview
和UISearchDisplayController
故事板。UISearchDisplayController和UITableView原型單元崩潰
我想從self.tableview(它連接到故事板中的主桌面視圖)使用自定義原型單元格。它工作正常,如果self.tableview
已返回至少1個單元格,當我加載我的視圖時,但如果self.tableview
不加載單元格(因爲沒有數據),並加載UISearchBar
和搜索,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
中創建,所以這是原因?
你可以發佈'configureCell:atIndexPath:'方法的代碼嗎?問題可能出在 –
之前,它崩潰之前,它會到達那裏......我將添加它雖然 – mootymoots
上面添加...並沒有真正做很多 – mootymoots