Ho una installazione UIViewController
in uno storyboard con tableview
e UISearchDisplayController
.UISearchDisplayController e UITableView arresto anomalo prototipo cella
Sto cercando di utilizzare una cella prototipo personalizzata da self.tableview (che è connessa alla tabella principale nello storyboard). Funziona bene se self.tableview
ha restituito almeno 1 cella quando carico la vista, ma se self.tableview
non carica una cella (poiché non ci sono dati) e carico la UISearchBar
e la ricerca, il metodo cellForRowAtIndexPath:
si blocca:
- (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;
}
errori
*** 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})
mio fetchedResultsController sembra avere dati (1 sezione, 2 f) al punto suddetto metodo viene chiamato. Si blocca sulla linea dequeueReusableCellWithIdentifier
.
Eventuali suggerimenti/idee? Dovrebbe deselezionare la cella prototipo da self.tableview
, ma suppongo che non sia stato creato nessuno in self.tableview
quindi questa è la causa?
Puoi pubblicare il codice di 'configureCell: atIndexPath:' metodo?Il problema potrebbe essere lì –
si blocca prima che arrivi ... Lo aggiungerò anche se – mootymoots
aggiunto sopra ... non fa davvero molto – mootymoots