要在不使用动画的情况下执行UICollectionView的reloadData,可以使用performBatchUpdates方法。
示例代码如下:
collectionView.performBatchUpdates({
collectionView.reloadSections(IndexSet(integer: 0))
}, completion: nil)
这个方法会在一个闭包中执行数据更新,并在闭包结束后刷新指定的sections,从而更新collectionView的数据。在这个示例中,我们使用了reloadSections方法来刷新第一个section。你可以根据需要来刷新更多的sections。
请注意,performBatchUpdates方法不会执行动画效果,而是立即刷新collectionView的数据。