之前用下面的方法现在图片,有时候会出现图片没有下载成功显示:

- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder;

后来研究下,还有下面的方法:

- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options;

重点就在这个SDWebImageOptions上,文档提示如下:

typedef NS_OPTIONS(NSUInteger, SDWebImageOptions) {

/**

* 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.

*/

SDWebImageRetryFailed = 1 << 0,

/**

* By default, image downloads are started during UI interactions, this flags disable this feature,

* leading to delayed download on UIScrollView deceleration for instance.

*/

SDWebImageLowPriority = 1 << 1,

/**

* This flag disables on-disk caching

*/

SDWebImageCacheMemoryOnly = 1 << 2,

/**

* This flag enables progressive download, the image is displayed progressively during download as a browser would do.

* By default, the image is only displayed once completely downloaded.

*/

SDWebImageProgressiveDownload = 1 << 3,

/**

* Even if the image is cached, respect the HTTP response cache control, and refresh the image from remote location if needed.

* The disk caching will be handled by NSURLCache instead of SDWebImage leading to slight performance degradation.

* This option helps deal with images changing behind the same request URL, e.g. Facebook graph api profile pics.

* If a cached image is refreshed, the completion block is called once with the cached image and again with the final image.

*

* Use this flag only if you can't make your URLs static with embedded cache busting parameter.

*/

SDWebImageRefreshCached = 1 << 4,

/**

* In iOS 4+, continue the download of the image if the app goes to background. This is achieved by asking the system for

* extra time in background to let the request finish. If the background task expires the operation will be cancelled.

*/

SDWebImageContinueInBackground = 1 << 5,

/**

* Handles cookies stored in NSHTTPCookieStore by setting

* NSMutableURLRequest.HTTPShouldHandleCookies = YES;

*/

SDWebImageHandleCookies = 1 << 6,

/**

* Enable to allow untrusted SSL certificates.

* Useful for testing purposes. Use with caution in production.

*/

SDWebImageAllowInvalidSSLCertificates = 1 << 7,

/**

* By default, image are loaded in the order they were queued. This flag move them to

* the front of the queue and is loaded immediately instead of waiting for the current queue to be loaded (which

* could take a while).

*/

SDWebImageHighPriority = 1 << 8,

/**

* By default, placeholder images are loaded while the image is loading. This flag will delay the loading

* of the placeholder image until after the image has finished loading.

*/

SDWebImageDelayPlaceholder = 1 << 9,

/**

* We usually don't call transformDownloadedImage delegate method on animated images,

* as most transformation code would mangle it.

* Use this flag to transform them anyway.

*/

SDWebImageTransformAnimatedImage = 1 << 10,

/**

* By default, image is added to the imageView after download. But in some cases, we want to

* have the hand before setting the image (apply a filter or add it with cross-fade animation for instance)

* Use this flag if you want to manually set the image in the completion when success

*/

SDWebImageAvoidAutoSetImage = 1 << 11

};

这个文档解释的很详细,然后将options设置为SDWebImageRetryFailed(默认下载图片失败后就不会再次下载了,该选项会让下载失败的重新下载) ,解决了问题.还有其他很多选项,在相应的场合都会有用的.

SDWebImage下载图片有时候无法成功显示出来的更多相关文章

  1. 李洪强iOS开发之 - 实现九宫格并使用SDWebImage下载图片

     李洪强iOS开发之 - 实现九宫格并使用SDWebImage下载图片  源码:  // //  ViewController.m //  08-九宫格扩展 // //  Created by 李洪强 ...

  2. 使用SDWebImage下载图片,sharedDownloader方法下载成功,new 方法下载失败

    一,经历 1.使用 new 方法创建下载对象时,下载图片总是失败,而且不会执行成功或失败后的回调. 2.参考别人的代码,用的是sharedDownloader来创建下载对象,可以顺利下载图片. 3.看 ...

  3. SDWebImage下载图片的使用

    第一步,下载SDWebImage,导入工程.github托管地址https://github.com/rs/SDWebImage 第二步,在需要的地方导入头文件 1 #import "UII ...

  4. 多线程下载图片,滑动tableView崩溃--资源抢夺问题

    最近练习使用NSoperation模拟SDWebImage下载图片,发生了崩溃的问题,还专门写博客记录这件事情: http://www.cnblogs.com/tufei7/p/7074030.htm ...

  5. tableView异步下载图片/SDWebImage图片缓存原理

    问题说明:假设tableView的每个cell上的imageView的image都是从网络上获取的数据.如何解决图片延迟加载(显示很慢).程序卡顿.图片错误显示.图片跳动的问题. 需要解决的问题: 1 ...

  6. IOS开发-第三方SDWebImage下载网络图片的使用

    从网络上请求图片时,没有使用第三方的话,下载会很慢,而且堵塞线程,还要自己处理多线程问题,效果还非常不明显,使用了SDWebImage这个第三方类库之后,下载图片就变的容易多了. SDWebImage ...

  7. 有关UIImageView+AFNetworking 下载图片的线程问题

    今天写了一个demo,从服务器获取图片,然后显示在cell上,大家都知道cell的重用机制,当往下拉的时候,上面的cell遮住了,下面的cell就会重用被遮住的cell, 贴代码: NSString ...

  8. [翻译] AsyncImageView 异步下载图片

    AsyncImageView  https://github.com/nicklockwood/AsyncImageView AsyncImageView is a simple extension ...

  9. C++根据图片url下载图片

    需要使用到URLDownloadToFile()函数,该函数在头文件<urlmon.h>中声明. URLDownloadToFile()函数的定义如下: HRESULT URLDownlo ...

随机推荐

  1. TCP 状态详解 -转载

    TCP 是一个面向连接的协议,无论哪一方向另一方发送数据之前,都必须先在双方之间建立一条连接.本节将详细讨论一个TCP 连接是如何建立的以及通信结束后是如何终止的. 建立一个 TCP 连接 TCP使用 ...

  2. 理论基础知识之————KB Kb Kbps 相关单位的区别和换算

    换算公式 8bit(位)=1Byte(字节) 1024Byte(字节)=1KB 1024KB=1MB 1024MB=1GB 1024GB=1TB 容量是大写的  B 而传输的速度是小写的  b bps ...

  3. C语言习题(结构)

    实际应用中经常会用到二维平面上的点,点的操作包括设置点的位置( pointT setPoint(double x , double y ) ),显示第n个点的位置( void showPoint(po ...

  4. JQuery 添加节点

    Mark一段自己写的添加节点的代码 function reply2(){ $( "<div class=sec1-div5>"+"<div class= ...

  5. 网易云音乐PC端刷曲快捷键

    文章首发于szhshp的第三边境研究所(szhshp.org), 转载请注明 网易云音乐PC端刷曲快捷键   好吧我承认我特别懒 云音乐其实做的还不错,FM推荐的算法明显比虾米好. 虾米可以听的曲子都 ...

  6. Android开发:在布局里移动ImageView控件

    在做一个app时碰到需要移动一个图案的位置,查了一上午资料都没找到demo,自己写一个吧 RelativeLayout.LayoutParams lp = new RelativeLayout.Lay ...

  7. PageRank理论与实践及用户评分应用PeopleRank算法

    PageRank,网页排名,又称网页级别.Google左侧排名或佩奇排名,是一种由根据网页之间相互的超链接计算的技术,而作为网页排名的要素之一. Google用它来体现网页的相关性和重要性,在搜索引擎 ...

  8. 用excel做分组散点图

    散点图主要观察两组变量间的趋势和分布,如果变量多于两组,仍旧使用散点图的话,那所有点都会集中在同一显示区域内,使人无法准确判断,此时一般使用散点图矩阵进行两两比较.除此之外,如果并不关心组与组之间的关 ...

  9. 【J-meter】变量加密之Bean shell使用

    参考资料: http://www.cnblogs.com/puresoul/p/4915350.html http://www.cnblogs.com/tester-hehehe/p/5466364. ...

  10. Github windows客户端简单使用教程

    1. 首先到官网下载Github客户端,官网地址:https://desktop.github.com/ 2. 点击上图红框的按钮开始下载客户端. 3. 双击下载好的客户端,开始安装. 双击之后出现一 ...