SDWebImage showing placeholder for images in cache

て烟熏妆下的殇ゞ 提交于 2019-12-06 10:28:16

问题


Using SDWebImage 3 in an iOS 5.1 project (iPad).

We show fairly large images( 700x500), and we have lots of them (+1000). We are prefetching the images and caching to disk and then allows the user browse through them.

It works fine. Except that while you browse through the images you always see for an slight moment that the placeholder is displayed, creating a very annoying effect.

In my use case it would be much more preferable to wait the small time to check the disk cache and process than displaying a placeholder for less than half a second (it basically just blinks).

My issue is similar to this one: How to get filesystem path to image cached with SDWebImage (iOS). Note: the approach of trying to fine out the filesystem path of the cache is wrong in my opinion. I am just referencing it because it also explains my use-case.

What I would wish to have is a way to tell SDWebImage to not use the placeholder if the image is in local storage. If I can't do that I might need to look for other libraries (I welcome advise).

Note: we are also using RestKit (0.20) + AFNetworking.


回答1:


Following @sergio's advise I modified SDWebImage. For anybody interested there is a forked version of the project: https://github.com/josea/SDWebImage

The usage is: [imageView setImageWithURL:url placeholderImage:[UIImage imageNamed:@"placeholder.png"] syncDiskLoad:YES];

I will put a pull request to the owner to see if my changes are incorporated to the master branch.

Update:

You can just do this to avoid the flickering (this works with the master branch of the project):

[imageView setImageWithURL:url placeholderImage:imageView.image options:0 
 progress:^(NSUInteger receivedSize, long long expectedSize) {
        imageView.image = [UIImage imageNamed:@"QuestionMarkFace.png"];
 } completed:nil];


来源:https://stackoverflow.com/questions/15034283/sdwebimage-showing-placeholder-for-images-in-cache

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!