【发布时间】:2019-11-22 06:57:17
【问题描述】:
我在我的项目中使用 UICollectionView 来显示新闻提要。当我移动到集合视图的顶部时,我可以使用拉动刷新手势加载 20 个较旧的帖子。我的问题是当我加载较旧的帖子时,最旧的帖子(收藏视图单元格)出现在收藏视图的顶部。我想要的是从我做出拉动刷新手势的点开始。
我在我的项目中使用 DeepDiff 库来重新加载集合视图
self.collectionView.reload(changes: changes, updateData: {
self.cellViewModels = layout.viewModels
})
以下是描述我的问题的视频链接: https://www.youtube.com/watch?v=zlfWrjF-RDo
【问题讨论】:
-
旧消息上传后调用 collectionView.scrollToItem(at: path, at: .top, animated: false)
-
重新加载时。你如何在 func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell 中处理你的数据源
标签: ios swift uicollectionview collectionview