我有一个带有许多项的UICollectionView。我正在将其用于商店,并希望在单击单元格时编辑单元格中的内容。当我单击单元格时,仅供测试,我删除了背景,但是当我单击单元格时,它从未被删除。当我添加一个打印函数时,它仍然打印出来,所以我知道这个方法被调用了。
我有一个UICollectionView类,其中包含以下功能:
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) as! Shop1CollectionViewCell
cell.clickedOn()
collectionView.reloadItems(at: [indexPath])
}
我有一个单元格的类:
class Shop1CollectionViewCell: UICollectionViewCell {
@IBOutlet weak var Label: UIView!
@IBOutlet weak var background: UIImageView!
func clickedOn(){
background.transform = CGAffineTransform(scaleX: 0.1, y: 0.1)
}
}
有什么方法可以更新单元格中的内容吗?它似乎被锁定,无法更改,或者不断重置图像。