SDWebimage

作者: 一代骄马 | 来源:发表于2017-09-24 12:46 被阅读3次
    SDWebimage SDWebimage 1.解决问题   1)图片重复下载的问题  —a,没有使用缓存(内存缓存,沙盒缓存)  b,网络慢时,快速滑动,图片没有下载完成,也没有取消下载,所以会重复下载  2)卡顿的问题 —a,重复下载 b,在主线程上下载  3)网络问题  4)线程问题:只需要开一次子线程就够了  5)数据错乱问题 :没有占位图片的情况下,网络慢,滑动块,复用出问题  6)url为空的容错处理  7)内存警告的问题  8)失效的url不会被重复下载
    最大并发数网络请求超时的具体时间


    - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock;
    1.options-SDWebImageOptions
        SDWebImageRetryFailed = 1 << 0,(默认情况下,当一个url下载失败,这个url就会加入黑名单,下次禁止尝试下载,这个参数禁止加入黑名单的操作)
        /**    * 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(默认情况下,在交互的时候图像也会下载,但是这个参数禁止ui交互时下载图像,例如在UIScrollView减速的时候延迟下载)
        SDWebImageCacheMemoryOnly = 1 << 2,(仅使用内存缓存,废除磁盘下载)
        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,(在url相同的时候,但是图片更新了,可以使用这个参数进行图片刷新)
        /**    * 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

    SDWebImageDecoder—对image的解码工作为什么对image进行解码不解码是用imageNamed来加载image,系统会默认在主线程立即进行图片的解码工作,生成控件可以直接使用的位图。大量调用imageNamed就会产生卡顿。解决方法:1.是用imageWithContentsOfFile2.把解码放到子线程中去





    相关文章

      网友评论

        本文标题:SDWebimage

        本文链接:https://www.haomeiwen.com/subject/yaskextx.html