Est-il impossible de supprimer plusieurs lignes de UITableView sans ajouter de nouvelles lignes? Je pensais qu'il y avait un support pour l'insertion et la suppression de lots, mais il semble que vous ne pouvez ajuster la taille de la table que d'un élément du compte précédent.Suppression de plusieurs lignes sans en ajouter dans UITableView
Lorsque je tente d'enlever un tas de lignes sans ajouter quelque chose de nouveau, je reçois l'erreur:
Invalid update: invalid number of rows in section 2. The number of rows contained in an existing section after the update (3) must be equal to the number of rows contained in that section before the update (0), plus or minus the number of rows inserted or deleted from that section (1 inserted, 0 deleted).'
Voilà comment je fais les suppressions:
// The section initially has 7 rows. I want to remove 5 of them.
// The underlying table store data has been cleared of the 5 rows
// content as of this point
int newRowCount = 5;
int aSection = 2;
// Create the index paths of the rows I want to delete
NSMutableArray *deletePaths = [NSMutableArray arrayWithCapacity:newRowCount];
for (int ix = 0; ix < newRowCount; ++ix)
{
[deletePaths addObject:[NSIndexPath indexPathForRow:ix inSection:aSection]];
}
// Start the updates
[aTableview beginUpdates];
if (deletePaths && [deletePaths count] > 0)
{
[aTableview deleteRowsAtIndexPaths:deletePaths
withRowAnimation:UITableViewRowAnimationNone];
}
[aTableview endUpdates];
uitableview Apple Documentation que je suis: link text