0
我希望每個CollectionViewCell都能顯示圖像並隱藏標籤,如果它被點擊。但是,如果用戶滾動圖像突然顯示在其他沒有被觸及的地方。我如何識別某些細胞?識別唯一的CollectionViewCells
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 (cell.myLabel.hidden) {
cell.myLabel.hidden = false
cell.MyImageView.image = nil
}
else {
cell.myLabel.hidden = true
cell.MyImageView.image = UIImage(named:"1")!
}
}
你能舉個例子嗎? – maidi