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