Tôi có thiết lập UIViewController
trong bảng phân cảnh có tableview
và UISearchDisplayController
.Tai nạn tế bào nguyên mẫu UISearchDisplayController và UITableView
Tôi đang cố gắng sử dụng ô mẫu thử tùy chỉnh từ self.tableview (được kết nối với chế độ xem bảng chính trong bảng phân cảnh). Nó hoạt động tốt nếu self.tableview
đã trả lại ít nhất 1 ô khi tôi tải chế độ xem của tôi, nhưng nếu self.tableview
không tải ô (vì không có dữ liệu) và tôi tải lên UISearchBar
và tìm kiếm, phương pháp cellForRowAtIndexPath:
lỗi:
- (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;
}
lỗi:
*** 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})
My fetchedResultsController dường như có dữ liệu (1 phần, 2 hàng) tại thời điểm các phương pháp trên được gọi. Nó treo trên dòng dequeueReusableCellWithIdentifier
.
Bất kỳ con trỏ/ý tưởng nào? Nó nên dequeue các tế bào nguyên mẫu từ self.tableview
, nhưng tôi đoán là không có ai được tạo ra trong self.tableview
vì vậy đây là nguyên nhân?
Bạn có thể đăng mã của phương thức 'configureCell: atIndexPath:' không?Vấn đề có thể là ở đó –
nó bị treo trước khi nó đến đó ... Tôi sẽ thêm nó mặc dù – mootymoots
thêm ở trên ... không thực sự làm nhiều – mootymoots