我显示了单元格,但是当我按下按钮时,我希望图像显示在集合视图单元格中

时间:2016-03-10 12:47:43

标签: ios swift uicollectionviewcell

当我按下按钮

时,我想从数组中插入图像
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {


       let cell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath)
        cell.backgroundColor = UIColor.orangeColor()

        return cell
    }




    func buttonCreateStickerPressed(sender: UIButton!){
        let stickerName = "Sticker Number "+String(stickerDictionary.count+1)
        let stickerNumber = stickerDictionary.count+1
        makeSticker(stickerName, stickerNumber: stickerNumber)
        // let count = stickerArray.count



    }

1 个答案:

答案 0 :(得分:0)

您可以尝试reloadData然后设置图像,或者是否只应对某些索引进行处理,您可以尝试reloadDataForRowIndexes:columnIndexes,然后在所选行中设置图像