簡體   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