Swift UICollectionView cellForItemAt在插入项后未调用(在:)-如何预加载下一个单元格?
我正在使用全屏单元格制作水平UICollectionView 单元格中有WKWebview,它加载下一个单元格的url 加载下一个url时,将插入新单元格Swift UICollectionView cellForItemAt在插入项后未调用(在:)-如何预加载下一个单元格?,swift,webview,collectionview,Swift,Webview,Collectionview,我正在使用全屏单元格制作水平UICollectionView 单元格中有WKWebview,它加载下一个单元格的url 加载下一个url时,将插入新单元格 extension ViewController { func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { guard let ce
extension ViewController {
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: WebCell.reuseId, for: indexPath) as? WebCell else { fatalError("Unexpected indexPath") }
cell.configure()
cell.startLoadingURL(urls[indexPath.item])
return cell
}
}
我想做的是——提前渲染下一个单元格
问题是-cellForItemAt方法在insertItems(at:)之后未调用
但当我减小单元格的大小以便下一个单元格可见时,就会调用cellForItemAt方法并渲染下一个单元格
我想在不减小单元格大小的情况下预加载下一个单元格。
有什么解决方法吗?您可以使用
显示单元格的方法
func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
<#code#>
}
func collectionView(collectionView:UICollectionView,willDisplay单元格:UICollectionViewCell,forItemAt indexPath:indexPath){
}
func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
<#code#>
}