我想将标签隐藏在被点击的单元格中,而是显示图像。但我只想在具有特定索引的单元格已设置为 imageView 时才这样做。如果将单元格设置为 imageView,则处理单元格和存储的最佳方法是什么?我该如何使用该prepareForReuse
方法?
直到现在我都是这样做的,但是因为细胞被重复使用了。图像在滚动时显示在其他单元格中。
override func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
println("user tapped on door number \(indexPath.row)")
let cell = collectionView.cellForItemAtIndexPath(indexPath) as! MyCollectionViewCell
if (cell.myLabel.text == "1") {
one = true
if(seven = true) {
if (cell.myLabel.hidden) {
cell.myLabel.hidden = false
cell.MyImageView.image = nil
}
else {
cell.myLabel.hidden = true
cell.MyImageView.image = UIImage(named:"1")!
}
}
}