繁体   English   中英

我已显示该单元格,但我希望在按下按钮时将图像显示在集合视图单元格中

[英]I have the cell displayed but I want the image to be displayed in the collection view cell when i press the button

我想在按下按钮时从数组中插入图像

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



    }

您可以尝试reloadData然后设置图像,或者如果只对某些索引进行设置,则可以尝试reloadDataForRowIndexes:columnIndexes然后在选定的行中设置图像

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM