【问题标题】:I have the cell displayed but I want the image to be displayed in the collection view cell when i press the button我显示了单元格,但是当我按下按钮时,我希望图像显示在集合视图单元格中
【发布时间】:2016-03-10 12:47:42
【问题描述】:

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

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



    }

【问题讨论】:

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

标签: ios swift uicollectionviewcell


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-05
    • 1970-01-01
    相关资源
    最近更新 更多