这段代码对你有意义吗?我试图在collectionView:didSelectItemAtIndexPath:
上触发的相同小区标识符上添加不同的内容:
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
println("bosen kelima")
if (collectionView == self.filterCollectionView) {//here
println("First Content")
let cell = self.filterCollectionView.dequeueReusableCellWithReuseIdentifier("FILTER_CELL", forIndexPath: indexPath) as! FilterThumbnailCell
var filterThumbnail = self.filterThumbnails![indexPath.row] // this one through bottom of this function will be deleted and moved to "didSelectItemAtIndexPath"
var filterThumbnailTwo = self.secondFilterThumbnails![indexPath.row]
cell.filterTitle.text = filterThumbnail.filterName
//Lazy Loading
if filterThumbnail.filteredThumbnail != nil {
cell.imageView.image = filterThumbnail.filteredThumbnail
}
else {
cell.imageView.image = filterThumbnail.originalThumbnail
//filterThumbnail is a class instance
filterThumbnail.generateThumbnail({ (image) -> Void in
if let cell = collectionView.cellForItemAtIndexPath(indexPath) as? FilterThumbnailCell {
cell.imageView.image = image
}
})
}
if filterThumbnailTwo.filteredThumbnail != nil {
cell.imageView.image = filterThumbnailTwo.filteredThumbnail
}
else {
cell.imageView.image = filterThumbnailTwo.originalThumbnail
//filterThumbnail is a class instance
filterThumbnailTwo.generateThumbnail({ (image) -> Void in
if let cell = collectionView.cellForItemAtIndexPath(indexPath) as? FilterThumbnailCell {
cell.imageView.image = image
}
})
}
return cell
}
}
如果它没有意义,你能给我解决方案吗?我已经看了近一周的解决方案,但仍然没有线索
答案 0 :(得分:0)
有什么不同的内容?
如果您具有不同状态的相同Cell类型,则需要Bool(2个状态)或2个或更多状态的枚举。
然后检查单元格的状态并执行您需要的操作。您还需要根据需要从正确的对象更新单元格状态。