您的位置:首页 > 大数据 > 人工智能

SDWebImage加载图片URL第一次失败,后面图片URL存在不刷新的问题

2016-12-21 17:27 1131 查看
业务需求,有时候会首先出现图片的网络URL地址,但是并没有显示出来,使用SDWebImage显示图片如下

self.itemImageView sd_setImageWithURL:<#(nullable NSURL *)#>];

但是发现,后面有图片了,再去刷新,无论如何也刷新不出来这图片。
最后发现SDWebImage里面有个说明,如果加载某个图片的URL失败,SDWebImage会把这个地址加入一个黑名单,后面就不会再重新加载这个URL请求。

     * By default, when a URL fail to be downloaded, the URL is blacklisted so the library won't keep trying.
但是有个Option标签,可以解决这个问题

    /**
     * By default, when a URL fail to be downloaded, the URL is blacklisted so the library won't keep trying.
     * This flag disable this blacklisting.
     */
[self.itemImageView sd_setImageWithURL:[NSURL URLWithString:imgUrlStr] placeholderImage:[UIImage imageNamed:@"iv_message_failed"] options:SDWebImageRetryFailed];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息