我想在按下按钮时插入数组中的图像
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,然后在选定的行中设置图像
关于ios - 我显示了单元格,但我希望当我按下按钮时图像显示在 Collection View 单元格中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35916951/