Reusable cell old image showing

后端 未结 6 718
醉话见心
醉话见心 2021-01-12 07:30

I am facing a problem when scrolling from top to bottom of my tableview. The reusable cell shows old image until new image download is completed.

It sh

6条回答
  •  太阳男子
    2021-01-12 08:19

    You can set your default image in ItemTableViewCell when the cell is initialized

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
        self.image= defaultImage
    }
    

    Edit

    func configureCell(iteminfo:ItemInfo , img1 : UIImage? , img2 : UIImage? ){
    
            if img1 != nil {
                imageViewItemPic.image = img1
            }
            else{
                print("hi1")
               imageViewItemPic.image = UIImage(named: "resto-placeholder.png")
    
                imageViewItemPic.setImageFromURL(url: iteminfo.imageUrl!)
            }
    
    
            if img2 != nil {
                imageViewCookerProfilePic.image = img2
    
            }
            else{
               imageViewItemPic.image = UIImage(named: "resto-placeholder.png")
                imageViewCookerProfilePic.setImageFromURL(url: iteminfo.cookerProfilePicUrl!)
            }
    
            labelItemHeading.text = iteminfo.heading
            labelItemDescription.text = iteminfo.description
    
    
        }
    

提交回复
热议问题