reload UITableViewCell only after Insert-Animation finished

ios, iphone, objective-c, uikit, uitableview

Solution

Try This..

U can reload your TableView After Completion of Animation.

[CATransaction begin];
[searchTableView beginUpdates];

[CATransaction setCompletionBlock: ^{
        [searchTableView reloadData];
    }];

[searchTableView deleteRowsAtIndexPaths: [NSArray arrayWithObjects: indexPath, nil]
                       withRowAnimation: UITableViewRowAnimationAutomatic];

[searchTableView endUpdates];

[CATransaction commit];

Problem

so i'm inserting a `UITableViewCell` into my tableView. ``` [searchTableView beginUpdates]; [searchTableView insertRowsAtIndexPaths:@[newIndexPath] withRowAnimation:UITableViewRowAnimationTop]; [searchTableView endUpdates]; ``` after this i'm running an asynchronous request which updates the tableviewcell with a fade animation. ``` [someRequestWithCompletion:^(id data) { dispatch_async(dispatch_get_main_queue(), ^{ [searchTableView beginUpdates]; [searchTableView reloadRowsAtIndexPaths:@[newIndexPath] withRowAnimation:UITableViewRowAnimationFade]; [searchTableView endUpdates]; }); }]; ``` but it is possible that this request finishes before the insert animation is finished. if the request finishes after the insert-animation, there is no problem, if it finishes before and calls a `reloadRowsAtIndexPaths` on the same cell that is currently inserting, the cell displays immediately and forces a reload while the insert-animation fades out. is there a way to trigger the reload update after the cell is completely inserted? what would be the best way to do this? if there are any questions, please let me know in the comments

Original source