简体   繁体   English

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

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

I want to insert images from array 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.

相关问题 图片未显示在收藏夹视图单元格中 - Images not displayed in collection view cell 如何以编程方式更改显示在单元格中的UIImageView中的图像? - How can I change the image displayed in an UIImageView in a cell programmatically? 当我在iOS中按Tab单元格时,viewDidLoad()每次都要调用 - viewDidLoad() want to call everytime when I press tab cell in iOS 当我在表格视图单元格中的uiimageview上添加长按手势时,Uiimageview没有显示正确的图像 - when I am adding Long Press Gesture on uiimageview in Table View Cell .Uiimageview Is not showing With correct Image 当我单击垂直索引按钮时,表视图单元格中有按钮 - I have button in table view cell when I click the perticular index button state will change 我可以在iOS通知中显示图像吗? - Can I have an image displayed in an iOS notification? 我想创建自定义日历,所以我使用了JTAppleCalendar并想在集合视图单元格中显示日期 - I want to create custom calendar so i used JTAppleCalendar and want to display date in collection view cell 按下按钮后仅显示第一句 - Only the 1st sentence is displayed after I press the button 双击集合视图单元格时如何使图像可见? - How do I make image visible when collection view cell is double tapped? 当我将渐变图像插入我的集合视图单元格时,label 文本在 swift 上变暗 - When I insert a gradient image to my Collection View Cell the label text darkens on swift
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM