在新项目上调用performBatchUpdates时,collectionview停止滚动

Wal*_*ker 5 uicollectionview swift

我正在插入新项目,因为用户向下滚动集合视图...我有一个问题,如果它们滚动得太快,集合视图会在插入新项目时停止滚动.

我最初的问题是我只是打电话self.collectionView.reloadData()而不是执行批量更新,但它目前正在做同样的事情......

这是我的代码

 let postIndex = self.posts.count
 let newPostIndex = newPosts.count
 let indexArray = (postIndex...postIndex+newPostIndex-1).map{IndexPath(item: $0, section: 0)}

 self.posts.append(contentsOf: newPosts)

  self.collectionView.performBatchUpdates({
           self.collectionView.insertItems(at: indexArray)
                            }, completion: nil)
Run Code Online (Sandbox Code Playgroud)

我已经有帖子所以我创建了一个索引数组,我需要更新并将它们插入performBatchUpdates中,但它看起来很不稳定,缺乏流畅的感觉.

我按照/sf/answers/2288432191/的建议尝试了CATransaction ,它完全滚动完全绕过所有新的东西,直到最后..

请协助