I have small problem with my conception of deleting rows in UITableView. After user deletes a row i do not want to fire:
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationRight];
Instead I want to change edited cell text and background without hiding it. My approach works quite well:
if (editingStyle == UITableViewCellEditingStyleDelete) { NSMutableArray *previous_points = [self.trip_arrayOfAllPoints mutableCopy]; [previous_points removeObjectAtIndex:indexPath.row]; self.trip_arrayOfAllPoints = nil; self.trip_arrayOfAllPoints = [[NSMutableArray alloc] initWithCapacity:[previous_points count]]; self.trip_arrayOfAllPoints = [previous_points mutableCopy]; self.trip_arrayOfAllPointsEDITED = [[NSMutableArray alloc] initWithCapacity:[previous_points count]]; self.trip_arrayOfAllPointsEDITED = [previous_points mutableCopy]; //[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationRight]; self.trip_isArrayOfAllPointsEDITED = YES; }
But after deleting a row it does not commit animation of dissapearing “DELETE” label on current cell. Is there a way around “Apple way” of deleting rows?
EDIT – I’ve worked it out
It’s pretty simple and plain. Just replace deleteRowsAtIndexPaths with:
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
After this “delete” animation disappears and cell is still in it’s place.
You mean that “Delete” button stays, even if you pressed it? On my iOS 5.1 emulator after
pressing “Delete” with empty:
“Delete” button disappears.