How to catch an animation end in deleteRowsAtIndexPaths

Viewed 3700

I was wondering if there is any possibility to catch if animation fired during deleteRowsAtIndexPaths did end? What I am trying to do is removing some all rows from UITableView except one that i tapped. Next I want to insert few rows into the same UITableView. Both operations are performed in separates beginUpadate/endUpdate blocks. The problem is that before deleting animation ends, the inserting animation starts and I want it be fired one after another because inserted rows are coming from external webservice.

I was thinking about wrapping inserting and deleting methods (in UITableView subclass) in methods where I could replace standard animation with custom ones and use objective-c blocks to fire one after another when the first ends but it appears to be imposible or I just can't do it.

Thanks in advance for your help!

3 Answers

From iOS 11 to above:

[tblProducts performBatchUpdates:^{
        [self->tblProducts deleteRowsAtIndexPaths:@[self.animDeleteIndex] withRowAnimation:UITableViewRowAnimationFade];
    } completion:^(BOOL finished) {
        [self->tblProducts reloadData];
}];
Related