UICollectionView标头会影响预取项

时间:2019-01-19 08:30:29

标签: ios swift uicollectionview uicollectionreusableview uicollectionviewflowlayout

在UICollectionView中使用 UICollectionViewFlowLayout的 sectionHeadersPinToVisibleBounds = true时, UICollectionViewDataSourcePrefetching的函数prefetchItemsAt indexPaths总是重复indexPath,例如:

collectionView(_:prefetchItemsAt:) [[0, 4], [0, 5], [0, 6], [0, 7]]
collectionView(_:prefetchItemsAt:) [[0, 4], [0, 5], [0, 6], [0, 7]]
collectionView(_:prefetchItemsAt:) [[0, 4], [0, 5], [0, 6], [0, 7]]
collectionView(_:prefetchItemsAt:) [[0, 4], [0, 5], [0, 6], [0, 7]]
collectionView(_:prefetchItemsAt:) [[0, 4], [0, 5], [0, 6], [0, 7]]
collectionView(_:prefetchItemsAt:) [[0, 4], [0, 5], [0, 6], [0, 7]]
collectionView(_:prefetchItemsAt:) [[0, 4], [0, 5], [0, 6], [0, 7]]
collectionView(_:prefetchItemsAt:) [[0, 4], [0, 5], [0, 6], [0, 7]]

当删除sectionHeadersPinToVisibleBounds = true(或将值设置为false)时,indexPaths数组在prefetchItemsAt indexPaths中变得正确:

collectionView(_:prefetchItemsAt:) [[0, 4], [0, 5], [0, 6], [0, 7]]
collectionView(_:prefetchItemsAt:) [[0, 4], [0, 5], [0, 6], [0, 7]]
collectionView(_:prefetchItemsAt:) [[0, 8], [0, 9]]
collectionView(_:prefetchItemsAt:) [[0, 10], [0, 11]]
collectionView(_:prefetchItemsAt:) [[0, 12], [0, 13]]
collectionView(_:prefetchItemsAt:) [[0, 14], [0, 15]]
collectionView(_:prefetchItemsAt:) [[0, 16], [0, 17]]

您能告诉我如何解决此问题吗?

0 个答案:

没有答案