Xcode 如何在Swift中UICollectionView的同一单元格标识符上应用不同的内容?

Xcode 如何在Swift中UICollectionView的同一单元格标识符上应用不同的内容?,xcode,swift,uicollectionview,Xcode,Swift,Uicollectionview,这个代码对你有意义吗?我试图将不同的内容放在同一单元格标识符上,该标识符在collectionView:didSelectItemAtIndexPath:上触发: func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { println("bosen kelima") if (co

这个代码对你有意义吗?我试图将不同的内容放在同一单元格标识符上,该标识符在
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
    }

}

如果没有道理,你能给我一个解决方案吗?我已经寻找解决方案将近一周了,但仍然不知道有什么不同的内容

如果相同的单元格类型具有不同的状态,则需要一个Bool(2个状态)或一个枚举来表示2个或更多状态


然后检查单元格的状态并执行所需操作。您还需要根据需要从正确的对象更新单元格状态。

您能给我一个代码示例吗,或者至少告诉我如何生成布尔?对不起,我是swift@helium3的新手