gpt4 book ai didi

ios - 获取图像时出错

转载 作者:行者123 更新时间:2023-11-28 15:06:51 24 4
gpt4 key购买 nike

我遇到了这个错误:

Thread 1: signal SIGABRT error I got in 3rd override function in cell declaration 

Could not cast value of type 'UICollectionViewCell' (0x10d27aa18) to 'collection.viewcell' (0x10a431130).

extension PhotoCollectionViewController {

override func numberOfSections(in collectionView: UICollectionView) -> Int {

return searches.count
}

//2
override func collectionView(_ collectionView: UICollectionView,
numberOfItemsInSection section: Int) -> Int {
return searches[section].searchResults.count
}

//3
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath) as! viewcell
//2
let flickrPhoto = photoForIndexPath(indexPath: indexPath)
print(flickrPhoto)
cell.backgroundColor = UIColor.white
//3
//cell.imageview.image = flickrPhoto.thumbnail
return cell
}
}

最佳答案

viewcell 更改为 UICollectionViewCell

 let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath) as! UICollectionViewCell

如果要使用自定义单元格,请先注册并使用。确保 registerClassdequeueReusableCell 是同一个类来解决问题。

self.registerClass(viewcell.self, forCellWithReuseIdentifier: reuseIdentifier)

let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as! viewcell

这会有所帮助。

关于ios - 获取图像时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48314375/

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