【发布时间】:2015-11-28 03:00:26
【问题描述】:
我想在点击时更改显示图像并在我的 collectionView 的单元格中隐藏标签。但是随着单元格的重复使用,还有其他单元格设置为在滚动时显示图像。 我该如何预防。我已经开始设置单元格的标签,但我不知道如何继续。
override func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
println("user tapped on cell number \(indexPath.row)")
let cell = collectionView.cellForItemAtIndexPath(indexPath) as! MyCollectionViewCell
cell.tag = indexPath.row
if (cell.tag == 0) {
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")!
}
}
【问题讨论】:
标签: ios swift uicollectionviewcell collectionview