gpt4 book ai didi

swift3 - iOS 10 中的 UICollectionView 预取数据源?

转载 作者:行者123 更新时间:2023-12-04 02:43:16 25 4
gpt4 key购买 nike

prefetchDataSources的目的是什么在 iOS 10 中引入?

我刚刚在 XCode 8 GM Seed 中运行了一个项目并开始出现错误:

MessagesExtension[17902:1238603] *** Assertion failure in -[UICollectionView _createPreparedSupplementaryViewForElementOfKind:atIndexPath:withLayoutAttributes:applyAttributes:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3599.6/UICollectionView.m:2161

enter image description here

最佳答案

UICollectionView gains a new property this year called prefetchDataSource. Just like the existing delegate and dataSource properties, we can simply set it to some object that implements the new UICollectionViewDataSourcePrefetching protocol.



这个协议(protocol)在 iOS 10 中是全新的,只需要我们实现一个新功能:
public func collectionView(_ collectionView: UICollectionView, prefetchItemsAt indexPaths: [IndexPath])

When this function is called, we can examine the indexPaths array we're passed in to know which cells are "coming up soon" and thus which cells we should probably begin loading the data for.



有关示例的详细理解,请参阅链接
UICollectionViewDataSourcePrefetching

关于swift3 - iOS 10 中的 UICollectionView 预取数据源?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39430231/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com