From bd9a198f2835353fd869e9bba554a9d329ae09ed Mon Sep 17 00:00:00 2001 From: Clifford Simon Date: Wed, 26 Feb 2014 14:01:40 -0800 Subject: [PATCH] rowIndex of cells updating when other cells are deleted --- RETableViewManager/RETableViewManager.m | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/RETableViewManager/RETableViewManager.m b/RETableViewManager/RETableViewManager.m index 0ce3c09..85a3a22 100755 --- a/RETableViewManager/RETableViewManager.m +++ b/RETableViewManager/RETableViewManager.m @@ -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--; + } } }