Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cell being populated with wrong images #1024

Closed
marcustoy opened this issue Jan 28, 2015 · 6 comments
Closed

Cell being populated with wrong images #1024

marcustoy opened this issue Jan 28, 2015 · 6 comments

Comments

@marcustoy
Copy link

Hi,

I'm currently using this code to set-up my images:

[cell.coverImage sd_setImageWithURL:[self.dataInJSONModel.Content[indexPath.row] CoverImage] placeholderImage:[UIImage imageNamed:@"imageplaceholder_general"]];

And my cells are often wrongly populated when I scroll. Guessed it is due to the cell reuse issue, where the async-downloaded images are populated to the cell that may have been re-used/disappeared. I have searched online and tried those recommendations but to no avail. Any standard method to solving this problem?

@mythodeia
Copy link
Contributor

@marcustoy in your cell subclass add the prepareforreuse method and nullify the image in your imageview

@marcustoy
Copy link
Author

marcustoy commented Jan 29, 2015

@mythodeia Thanks a lot! It solves the problem!!! You save my several hours of debugging and searching online. Thanks again!!

@siddhesh12
Copy link

Hi @mythodeia ,
I used above method, I followed almost all the tricks mentions over internet, but still problem exists. Is there any other solution for this ?

@mythodeia
Copy link
Contributor

@siddhesh12 there must be a cell reuse issue somewhere hidden in your code. check the demo project to see how it works. if still you have issues please share a demo project so everyone can take a look and help

@siddhesh12
Copy link

I got the solution for it. at the beginning I am calling sd_cancelImageLoadForState method. so when image gets download asynchronously it will never assign it to different cell which was previously reused. This was only used to happen when some cell do not have url from data model.

@ilyanengen
Copy link

ilyanengen commented Apr 26, 2018

Before setting new image to imageView add:

cell.imageView.sd_currentDownloadTask?.cancel()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants