SpaceX
SpaceX

Reputation: 2890

Prevent image overlay in image view swift

I have a tableViewCell with image view.

Even though I clear the imageView and set the image I get the below unintended behaviour, where one image is overlaid over the other.

enter image description here

Please advice how this could be resolved.

Code on Resetting Image in ImageView:

self.profileImageLabelTVCell.cellImageView.image     = nil   // Clearing previous image
self.profileImageLabelTVCell.cellImageView.image     = image

Here is the link for the tableViewCell code and roundedImageView class, that I've used. (Since SO did not allow the entire code to be posted here)

https://gist.github.com/pravishanth/14cdb8bf14dd8899b081bdc97988b985

Upvotes: 2

Views: 68

Answers (1)

inokey
inokey

Reputation: 6200

Add your reset image code to the TableViewCell's

func prepareForReuse() method.

override func prepareForReuse() {
    super.prepareForReuse()
    cellImageView.image = nil
}

Upvotes: 1

Related Questions