一、 今日做项目遇到图片复用问题,返回cell高度相同,由于网络不好出现图片复用,发现问题

 

Cell 图片加载方法如下:

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

    [selfsd_setImageWithURL:url placeholderImage:placeholder options:0progress:nilcompleted:nil];

}

 

更改为:

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

    [selfsd_setImageWithURL:url placeholderImage:placeholder options:options progress:nilcompleted:nil];

}

options 方法如下:

 

    /**

 

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

     Scrollview 滑动的时候,或者交互的时候,禁止下载图片,等非滑动时刻开始下载,默认情况下,图片会在交互发生的时候下载(例如你滑动tableview的时候),这个flag会禁止这个特性,导致的结果就是在scrollview减速的时候才会开始下载

 

     */

 

    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.

     图片逐步下载,这个flag会使图片边下载边显示,不用此方法是下载完成再一次性显示

 

     */

 

    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;

     使用Cookies的方法

 

     */

    SDWebImageHandleCookies = 1 << 6,

 

    /**

 

     * Enable to allow untrusted SSL certificates.

 

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

     允许不被信任的SSL证书

 

     */

    SDWebImageAllowInvalidSSLCertificates = 1 << 7,

 

 

 

    /**

 

     * By default, images are loaded in the order in which they were queued. This flag moves them to

 

     * the front of the queue.

     图片下载优先级最高,优先下载图片

 

     */

 

    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.

     默认情况下,占位图会在图片下载的时候显示.这个flag开启会延迟占位图显示的时间,等到图片下载完成之后才会显示占位图(有何意义?

 

     */

 

    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.

     我们通常不会在动画图像上调用transformDownloadedImage委托方法,因为大多数转换代码会对它进行转换,使用此标志来转换它们

 

     */

 

    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

 

只言片语 - cell 图片复用问题的更多相关文章

  1. cell 的复用机制

    一个问题引发的血案,以下是本侦探的探案过程的一部分:以下全部都是转载自别人的博客:http://blog.sina.com.cn/s/blog_9c3c519b01016aqu.html 转自:htt ...

  2. cell的复用机制

    以下全部都是转载自别人的博客:http://blog.sina.com.cn/s/blog_9c3c519b01016aqu.html 转自:http://www.2cto.com/kf/201207 ...

  3. Cell的复用机制问题总结

    创建方式汇总,注册和不注册Cell注册的两种方式 1.tableView registerNib:(nullable UINib *) forCellReuseIdentifier:(nonnull ...

  4. Tableview 优化Cell的复用机制01

    #import "ViewController.h" @interface ViewController ()<UITableViewDataSource> @end ...

  5. tableView中cell的复用机制

    TableView的重用机制,为了做到显示和数据分离,IOS tableView的实现并且不是为每个数据项创建一个tableCell.而是只创建屏幕可显示最大个数的cell,然后重复使用这些cell, ...

  6. QF——UITableViewCell性能优化(视图复用机制)

    这几篇博客总结的不错: 点击进入 点击进入 总结起来方案一般有以下几种: 1.不使用透明视图: 2.减少视图的个数: 3.cell复用机制:(重点) 4.图片缓存: 5.网络请求使用非主线程. 6.预 ...

  7. iOS tableViewCell 在cell赋值、网络加载照片位置偏移大小错乱,做一个类似qq列表的tableview 更新3

    更新3: 问题 加载慢!(一时间给的处理负载过大,要分散)在下载图片,判断状态后 对每个cell对图片灰置图片处理保存,影响了主线程的操作 :上拉加载时,无法上下滑动tableview 无法点击cel ...

  8. Android加载图片小结

    应用中用到图片加载需要解决的问题 无网络环境下图片不可用 图片的本地缓存,或者默认预加载的图片 低配置机型,加载图像资源超内存(OutOfMemory, OoM) 需要合理使用内存,尤其是bitmap ...

  9. Swift - 表格图片加载优化(拖动表格时不加载,停止时只加载当前页图片)

    列表的单元格中包含有图片在开发中很常见.通常我们可以直接在tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIn ...

随机推荐

  1. Sleep(0)的妙用

    在线程中,调用sleep(0)可以释放cpu时间,让线程马上重新回到就绪队列而非等待队列,sleep(0)释放当前线程所剩余的时间片(如果有剩余的话),这样可以让操作系统切换其他线程来执行,提升效率. ...

  2. Eclipse使用技巧总结(四)——代码重构专题

    二十四.重命名 这样重命名就方便多了,不需要一个一个去改了 二十五.移动类和方法 二十六.改变方法 二十七.转换匿名内部类到外部 二十八.提取接口 二十九.抽取成单独方法: Refactor--> ...

  3. LoadFromStr的使用中出现错误“未结束的字符串常量”

    最近遇到个奇怪的问题,就是关于js参数中待换行符时,出现了错误“为结束的字符串常量”. 解决方法是:不直接将该数据以参数形式传递,而是先将其赋值在一个隐藏的文本内,需要调用的函数里只需读取该文本里的内 ...

  4. Java SpringMVC实现国际化整合案例分析(i18n) 专题

    所谓国际化就是支持多种语言,web应用在不同的浏览环境中可以显示出不同的语言,比如说汉语.英语等.下面我将以具体的实例来举例说明: (1)新建动态Javaweb项目,并导入几个SpringMVC必需的 ...

  5. Android 4.0开发之GridLayOut布局实践

    在上一篇教程中http://blog.csdn.net/dawanganban/article/details/9952379,我们初步学习了解了GridLayout的布局基本知识,通过学习知道,Gr ...

  6. java中 8进制 10进制 2进制 16进制 相互转换

    十进制转成十六进制: Integer.toHexString(int i) 十进制转成八进制 Integer.toOctalString(int i) 十进制转成二进制 Integer.toBinar ...

  7. robot framework的使用说明

    robot framework安装说明1.安装python2.7.15运行安装包python-2.7.15.amd64.msi 2.robot framework(1)解压最新的压缩包如robotfr ...

  8. PBS 作业调度应用

    PBS(Portable Batch System),最初由 NASA 的 Ames 研究中心开发,主要为了提供一个能满足异构计算网络需要的软件包,用于灵活的批处理(Portable Batch Pr ...

  9. Linux性能测试 top衍生命令 atop/htop/slaptop

    1. Atop Atop 是一个类似 top 的工具,但比 top 更有料.通过 Atop,你能够监视 Linux 系统的性能状况,包括进程活动.CPU.内存.硬盘.网络等方面的使用情况等. 2. h ...

  10. Qt使用预编译头文件Using Precompiled Headers(提升10倍以上)

    预编译头文件是被很多编译器用来编译稳定的代码以及将编译好的稳定代码存储在二进制文件中用于提升编译性能.在随后的编译中,编译器将加载存储状态继续编译指定的文件.每一个随后的编译将更快,因为稳定的代码不需 ...