Summary: In editing mode, I'm deleting rows in a table view using a custom editing control, rather than the default red minus sign and delete confirmation button. Tick a row or multiple rows, then tap the Delete button in the tool bar. It's similar to the behavior seen in the Mail app. See the screenshot below.
Problem:
The animations produced by calls to deleteRowsAtIndexPaths:withRowAnimation:
are irregular. For example, here's what happens when I use the Bottom row animation (i.e., UITableViewRowAnimationBottom
) to delete the ticked row (Subject #7) in the screenshot:
This is occurring on both the simulator and on a device. The Automatic animation type (i.e., UITableViewRowAnimationAutomatic
) produces the same irregular behavior when deleting Subject #7 above.
The Top animation type works as expected in the simulator but produces inconsistent, jarring animations on a device.
The Fade type animation is the only animation that works as expected in both the simulator and on a device.
Details:
I'm targeting iOS 7, and using storyboard, pure auto layout, and Core Data.
Here's the action method where I delete the rows:
- (void)deleteButtonTapped:(UIBarButton *)sender
{
// update table view's data
[self.listOfItems removeObjectsAtIndexes:self.indexSetOfTickedRows];
// create index paths for ticked rows
NSMutableArray *indexPaths = [[NSMutableArray alloc] init];
[self.indexSetOfTickedRows enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) {
[indexPaths addObject:[NSIndexPath indexPathForRow:idx inSection:0]];
}];
[self.tableView deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationBottom];
// update Core Data and UI...
}
What I have tried:
The table cell subclass overrides layoutSubviews
. However, the irregular animations persist even when I comment out layoutSubviews
.
I also removed the custom tickable editing control from the table cells, then hard-coded the deletion of a specific row in the action method. The irregular animations persisted.
As suggested by others, I've tried calling deleteRowsAtIndexPaths:withRowAnimation:
between calls to beginUpdates
and endUpdates
. This does not resolve the issue.
Any suggestions on what to do next, or best guesses as to why I am seeing these irregular animations?
Update (iOS 7.1):
Issue remains after targeting iOS 7.1. Will continue to rely on fade animation.
Try calling
[self.listOfItems removeObjectsAtIndexes:self.indexSetOfTickedRows];
at the end of the function instead of at the beginning.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With