在reloadItemsAtIndexPaths之后避免使用UICollectionView的动画 [英] Avoid animation of UICollectionView after reloadItemsAtIndexPaths
本文介绍了在reloadItemsAtIndexPaths之后避免使用UICollectionView的动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
调用reloadItemsAtIndexPaths之后的UICollectionView动画项目(淡入淡出动画)。
UICollectionView animate items after reloadItemsAtIndexPaths is called (fade animation).
有没有办法避免这个动画?
Is there a way to avoid this animation?
iOS 6
推荐答案
你也可以试试这个:
UICollectionView *collectionView;
...
[UIView setAnimationsEnabled:NO];
[collectionView performBatchUpdates:^{
[collectionView reloadItemsAtIndexPaths:indexPaths];
} completion:^(BOOL finished) {
[UIView setAnimationsEnabled:YES];
}];
编辑:
我也找到了如果在UIView动画块中包装 performBatchUpdates
,则使用UIView动画而不是默认动画,因此您可以将动画持续时间设置为0,如下所示: / p>
I have also found that if you wrap performBatchUpdates
in a UIView animation block, the UIView animation is used instead of the default animation, so you can just set the animation duration to 0, like so:
[UIView animateWithDuration:0 animations:^{
[collectionView performBatchUpdates:^{
[collectionView reloadItemsAtIndexPaths:indexPaths];
} completion:nil];
}];
如果您想在插入和删除期间使用iOS 7弹性动画,这是非常酷的!
This is extra cool if you want to use iOS 7 springy animations during inserts and deletes!
这篇关于在reloadItemsAtIndexPaths之后避免使用UICollectionView的动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文