Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableView reloadSection and reloadRowsAtIndexPaths causes weird animation

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!

like image 871
Alan Avatar asked May 20 '13 14:05

Alan


2 Answers

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)
        }
like image 154
ad1Dima Avatar answered Nov 07 '22 19:11

ad1Dima


Below method worked for me: (for iOS 7 and better)

[UIView performWithoutAnimation:^{
    [tableView reloadSections:[NSIndexSet indexSetWithIndex:[indexPath section]] withRowAnimation:UITableViewRowAnimationNone];
}];
like image 9
Şafak Gezer Avatar answered Nov 07 '22 20:11

Şafak Gezer