我正在为我的 UITableView 进行延迟加载,所以我试图在图像更新时重新加载各个行。然而,我遇到了一个奇怪的问题。
当我打电话时,
[self.bubbleTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil] withRowAnimation:UITableViewRowAnimationNone];
或
[self.bubbleTableView reloadSections:[NSIndexSet indexSetWithIndex:[indexPath section]] withRowAnimation:UITableViewRowAnimationNone];
当我明确说没有动画时,它仍然会动画,动画是图像占据整个单元格并迅速缩小到正常大小。此外,如果我将其更改为任何其他动画,无论设置如何,它都会执行相同的动画。
如果我注释掉其中任何一个并只使用 reloadData 它工作正常,但我宁愿不做 reloadData 出于重新更新不需要更新的单元格的性能原因。
谢谢!
最佳答案
[UIView setAnimationsEnabled:NO];
[self.bubbleTableView reloadSections:[NSIndexSet indexSetWithIndex:[indexPath section]] withRowAnimation:UITableViewRowAnimationNone];
[UIView setAnimationsEnabled:YES];
它对我有用。
更新。与@Ş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)
}
关于objective-c - UITableView reloadSection 和 reloadRowsAtIndexPaths 导致奇怪的动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16651767/