Error de falla de afirmación al intentar eliminar una fila de una vista usable
-
13-12-2019 - |
Pregunta
A veces recibo este error al intentarlo de la fila de la UITYVIEW:
Fallo de afirmación en - [UITUITYVIEW _ENDCELLANIMATIONSWIPTONTXT:]
y otras veces que elimina la fila sin problemas.
Aquí está mi código:
- (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];
}
}
Solución
Suena como su numberfrowsinsection está devolviendo el entero incorrecto a veces cuando ingresa el modo de edición.
Otros consejos
No estoy tan seguro ... pero intente esto (trabajado para mí una vez)
Animar primero la eliminación de UITYVIEW, luego retire el objeto de la matriz.
if (editingStyle == UITableViewCellEditingStyleDelete)
{
// Animate deletion
NSArray *indexPaths = [NSArray arrayWithObject:indexPath];
[[self tableView] deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationFade];
[[self displayedObjects] removeObjectAtIndex:[indexPath row]];
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow