rowIndex of cells updating when other cells are deleted

This commit is contained in:
Clifford Simon
2014-02-26 14:01:40 -08:00
parent b36dee2c62
commit bd9a198f28

View File

@@ -305,12 +305,24 @@
item.deletionHandlerWithCompletion(item, ^{
[section removeItemAtIndex:indexPath.row];
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
for (int i = indexPath.row; i < section.items.count; i++) {
RETableViewItem *afterItem = [[section items] objectAtIndex:i];
RETableViewCell *cell = (RETableViewCell *)[tableView cellForRowAtIndexPath:afterItem.indexPath];
cell.rowIndex--;
}
});
} else {
if (item.deletionHandler)
item.deletionHandler(item);
[section removeItemAtIndex:indexPath.row];
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
for (int i = indexPath.row; i < section.items.count; i++) {
RETableViewItem *afterItem = [[section items] objectAtIndex:i];
RETableViewCell *cell = (RETableViewCell *)[tableView cellForRowAtIndexPath:afterItem.indexPath];
cell.rowIndex--;
}
}
}