Reputation: 3959
i have a uitableview with custom uitableviewcell; the cell consists of an image and few labels the image is downloaded remotely using this method
[SDWebImageDownloader downloaderWithURL:[NSURL URLWithString:url] delegate:self];
i use above method instead of the following: [cell.imageView setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"] placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
(ref https://github.com/rs/SDWebImage) because i need to do some post processing after downloading the image. because SDWebImageDownloader has a callback method when image finishes loading, that is why i am using it.
if i do
[cell.imageView setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"]
placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
[post processImage]
it is possible that i am post-processing an image before it is fully download, anyway this is not the issue but just letting you know the context
after doing some research, saome said i should cancel the loading request...but i have no idea if that is gonna help plus i don't know how to distinquish which one i should be really loading and which ones i should cancel
my problem is that when using SDWebImageDownloader, when scrolling through the uitableview, the images flicker, flickering in a way that, you see image slowly loading and changing from previous image to the other, at the end it does load the correct the image, but the flickering is not desired
it seems what is causing the problem is the call to SDWebImageDownloader and not the post-processing to the image i am doing that cause the delay or flickering, because in the SDWebImageDownloader callback, if i simply just assign the image, flickering still occurs.
i have no choice but to use SDWebImageDownloader, becuase i need to resize the image...anybody can tell me how to avoid the flickering? thanks
Upvotes: 1
Views: 1854
Reputation: 4271
Since updating the AFNetworking
library, what I noticed was, at times, the setImageWithURL:
from the AFNetworking
was invoked instead of from SDWebImage
.
I tackled it by using downloadWithURL:options:progress:completed:
from SDWebImageManager
.
I had a UITableView
(with custom cells) which I populated using data from the Foursquare API. The setImageWithURL:
method caused flickers. On the simulator(LAN), and iPhone5(WiFi), it seemed like a flicker. But on switching to 2G on the device, I noticed, an image from a different cell was being loaded in the imageView
, before the correct image was set.
I switched from setImageWithURL:
to downloadWithURL:options:progress:completed:
, by setting a placeholder image first, and then setting the image in the completion block of the downloadWithURL:options:progress:completed:
method. It became smoother, and resolved all flickers.
Upvotes: 0