Erreur de défaillance d'affirmation lorsque vous essayez de supprimer une ligne d'un utableview

StackOverflow https://stackoverflow.com//questions/9697530

Question

Parfois, je reçois cette erreur lors de la tentative de Delelte une ligne de l'utableview:

défaillance de l'affirmation dans - [utableview _endcellanimationswithContext:]

Et d'autres fois, il supprime la ligne avec pas de problèmes.

Voici mon code:

- (void) tableView:(UITableView *)tableView
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle 
 forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (editingStyle == UITableViewCellEditingStyleDelete)
    {
     [[self displayedObjects] removeObjectAtIndex:[indexPath row]];


     // Animate deletion
     NSArray *indexPaths = [NSArray arrayWithObject:indexPath];
     [[self tableView] deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationFade];

    }
}

Était-ce utile?

La solution

sonne comme votre NumberOfrowSectionSection renvoie le mauvais Entreger parfois lorsque vous entrez le mode d'édition.

Autres conseils

Pas si sûr .. mais essayez ceci (travaillé pour moi une fois)

Animez d'abord la suppression UitativeView, puis supprimez l'objet de la matrice.

if (editingStyle == UITableViewCellEditingStyleDelete)
    {
     // Animate deletion
     NSArray *indexPaths = [NSArray arrayWithObject:indexPath];
     [[self tableView] deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationFade];

    [[self displayedObjects] removeObjectAtIndex:[indexPath row]];

    }

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top