美文网首页
SDWebImage加载占位图闪烁的问题

SDWebImage加载占位图闪烁的问题

作者: Michale_Zuo | 来源:发表于2020-05-15 09:45 被阅读0次

 这次上线前,测试同事提出了为什么我们app首页的banner加载的时候会闪一下,我们一看会有短暂的闪烁,因为先渲染的是占位图,在渲染上次的缓存图片,然后在渲染请求回来的图片,在占位图和缓存图片的渲染过程中会有一个闪烁过程。我们就开始一起寻找问题,这个banner图片缓存框架用的是SDWebImage,我们就一层层排查,从首页代码刷新逻辑到轮播图控件,再到SDWebImage一层层排查最后发现了是SDWebImageOptions的问题。


Snip20200418_21.png Snip20200418_23.png Snip20200418_27.png
/**
     * By default, we query the memory cache synchronously, disk cache asynchronously. This mask can force to query disk cache synchronously to ensure that image is loaded in the same runloop.
     * This flag can avoid flashing during cell reuse if you disable memory cache or in some other cases.
     */

这个option配置就是同步加载磁盘缓存的图片,可以保证在当前runloop里面加载,避免闪烁的问题。开源库里解释说在cell复用的时候可以很有效的避免闪烁的问题。

相关文章

网友评论

      本文标题:SDWebImage加载占位图闪烁的问题

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