タップされたセルのラベルを非表示にして、代わりに画像を表示したい。しかし、特定のインデックスを持つセルが既に 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")!
}
}
}