-
Notifications
You must be signed in to change notification settings - Fork 186
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
Lazy Loading UITableView sometimes shows previously queued image #13
Comments
Because table cells are recycled, you need to call [AsyncImageLoader cancelLoadingImagesForTarget:] on the table cell image view before you set the new URL in your cellForRowAtIndexPath method, otherwise it may still be loading the image from a previous row. Could that be the problem? |
I wonder if I have an old version I don't see that method. Matt On Thu, Jun 28, 2012 at 4:28 PM, Nick Lockwood <
––––––––––––––––––––––––––––––––––––– ** Office: (479) 856-6177 |
Found it. I downloaded the new version as well. |
There was a similar approach in the earlier version's example code but it required you to know which URL you were cancelling. I've just updated the examples to demonstrate how to use the new cancel method. |
It still seems to be loading some other image after I ran this: [[AsyncImageLoader sharedLoader] cancelLoadingImagesForTarget:cell.imgPlayer]; |
Email your project to support at charcoal design dot co dot uk and I'll take a look. |
Dang Nick you are awesome. |
Let me do some more debugging and see if I can find it. My project is pretty big. |
If you send me the .m file for your table view controller I'll see if I can spot anything obvious. |
Sent. I really appreciate you supporting this even though you aren't getting paid. |
Wait... I'm not getting paid??! ;-) |
Haha.. do you have a donate button? |
Ah, I have an idea. You need to blank out the previous image in the cell after you recycle it, otherwise it will briefly show whatever image was in there the last time the cell was used before the new image loads to replace it. In my example I always set the image to a loading placeholder, but you aren't using one, so you probably need to nil out the image immediately after you dequeue the cell, like this:
|
That solved it. No where is that donate button? :) On Thu, Jun 28, 2012 at 5:47 PM, Nick Lockwood <
––––––––––––––––––––––––––––––––––––– ** Office: (479) 856-6177 |
There's one here: http://www.charcoaldesign.co.uk/source/cocoa Glad I could help. Nick |
Done. Btw the app this is in is called Trivi.al feel free to check it out On Thu, Jun 28, 2012 at 5:54 PM, Nick Lockwood <
––––––––––––––––––––––––––––––––––––– ** Office: (479) 856-6177 |
Thanks, will do. |
A better way to reset image is to reset it in
|
Genius.... |
Hi Guys, |
You need to cancel any loading images on the cell before reusing it. Setting imageURL to nil before setting it to the new URL should suffice. |
@nicklockwood: I'm seeing the same issue as @jabbarfast I have the following code (which I've checked gets called):
However, I still see previous images before the new ones load. I've tried that code in the cell and in the view. I am using a Could you provide any more ideas for me to explore please? Thanks in advance for your help and for creating an awesome library :) |
@iHiD && @jabbarfast I can't speak for a collectionView, but for a tableview: When creating a new cell I also create the imageView with a frame:
Give it a tag: Then I pass that to a basic imageView and add as subview to cell:
Then after you're done making the new cell, or if you're reusing a cell, but still in cellForRowAtIndex: AsyncImageView *imageView = (AsyncImageView *)[cell viewWithTag:10];
// Then I clear out the image by setting it to nil
Hope this helps because I had the same problem you're describing, just with a tableView |
I have a UITableView that is using your AsyncImageView (great stuff btw). If I scroll up and down, I often get a different image than was requested. It seems like it may be a problem with dequeing the proper cell. I usually have to scroll up and down a couple of times.
It seems like it comes when it should be showing default.
The text was updated successfully, but these errors were encountered: