2
这是我的Swift 3代码。我需要将图像放入通过Kingfisher缓存下载的数组中。实际上,图像现在显示在cell.itemImage中,但我无法将这些图像放到UIImage数组中。如何将图像放置在由Kingfisher缓存下载的阵列中?
任何人都可以帮忙吗?
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell
{
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) as! ViewItemsCVC
let Currency = UserDefaults.standard.string(forKey: "currency")
cell.NameLabel.text = self.itemName[indexPath.row]
cell.PriceLabel.text = "\(Currency ?? "INR") \(self.itemPrice[indexPath.row])"
let resource = ImageResource(downloadURL: URL(string: self.FullLink[indexPath.row])!, cacheKey: self.FullLink[indexPath.row])
cell.itemImage?.kf.setImage(with: resource)
return cell
}
你想图像添加到UIImage的数组有什么特别的原因吗? – kathayatnk
是的,我需要将图像传递给另一个类通过准备segue –
当用户单击单元格时是否要传递此图像?如果是这种情况,那么你不需要一个数组。 – Ramis