UITableView reloadSection and reloadRowsAtIndexPaths causes weird animation

Alan picture Alan · May 20, 2013 · Viewed 11.2k times · Source

I am doing lazy loading for my UITableView so I am trying to reload individual rows as the images get updated. I am however running into a strange problem.

When I call,

    [self.bubbleTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil] withRowAnimation:UITableViewRowAnimationNone];

OR

    [self.bubbleTableView reloadSections:[NSIndexSet indexSetWithIndex:[indexPath section]] withRowAnimation:UITableViewRowAnimationNone];

When I specifically say No Animation it still animates and the animation is the Image taking up the entire cell and shrinking rapidly into the normal size. Also, if I change it to any other animation, it does the same animation no matter what setting.

If I comment either one of those out and just use reloadData it works fine, but I'd rather not do reloadData for performance reasons of reupdating cells that don't need updating.

Thanks!

Answer

ad1Dima picture ad1Dima · Jun 24, 2014

Here was an answer

[UIView setAnimationsEnabled:NO];
[self.bubbleTableView reloadSections:[NSIndexSet indexSetWithIndex:[indexPath section]] withRowAnimation:UITableViewRowAnimationNone];
[UIView setAnimationsEnabled:YES];

It works for me.

UPD. Same with block by @Şafak-gezer

[UIView performWithoutAnimation:^{
    [self.bubbleTableView reloadSections:[NSIndexSet indexSetWithIndex:[indexPath section]] withRowAnimation:UITableViewRowAnimationNone];
}];

SWIFT

UIView.performWithoutAnimation {
            self.bubbleTableView.reloadSections(NSIndexSet(index: indexPath.section), withRowAnimation: UITableViewRowAnimation.None)
        }