Irregular animations from UITableView's deleteRowsAtIndexPaths:withRowAnimation:

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.

enter image description here

  • Auto Layout to dynamically size uilabel width
  • Failed to set () user defined inspected property on (UIButton)
  • How do I perform a fast pixellation filter on an image?
  • Can iPhone apps start on start-up?
  • UIActionSheet from UIAlertView
  • Fetch Record Assets in CloudKit Using Swift
  • 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:

    1. Subject #8 slides underneath and behind Subject #7
    2. Subject #8 is briefly hidden behind Subject #7
    3. Subject #8 replaces Subject #7 jarringly

    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.

    3 Solutions Collect From Internet About “Irregular animations from UITableView's deleteRowsAtIndexPaths:withRowAnimation:”

    Try calling
    [self.listOfItems removeObjectsAtIndexes:self.indexSetOfTickedRows];
    at the end of the function instead of at the beginning.

    Try adding [tableView beginUpdates]; and [tableView endUpdates];

    Maybe setting the alpha on the cell works as suggested here. Not sure though.
    problems with animation when deleting the last row of a TableView in ios7