更改图像时清除CATiledLayers缓存 [英] Clear CATiledLayers Cache When Changing Images

查看:80
本文介绍了更改图像时清除CATiledLayers缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有单个子视图的UIScrollView,一个由CATiledLayer支持的UIView。一切正常,只有一个例外:当我将图像从一个更改为另一个时,CATiledLayer会缓存之前的图像缩放级别。滚动然后在更新的图像加载之前显示旧图像一瞬间。

I have a UIScrollView with a single subview, a UIView backed by a CATiledLayer. All is working well with one exception: when I change images from one to another the CATiledLayer caches the previous images zoom levels. Scrolling around then displays the old image for a split second before the updated image loads.

有没有办法彻底清除CATiledLayer的缓存,因此它不会显示旧的图片? CATiledLayer显然知道支持图像已更改,因为它要求它为新图块委托......

Is there any way to totally clear out the CATiledLayer's cache so it doesn't show old images? The CATiledLayer obviously knows that the backing image changed because it asks it's delegate for new tiles...

推荐答案

我认为你正在制作这比它需要的要复杂得多。我相信你所要做的就是将你的CATiledLayer的内容设置为nil。

I think you are making this a little more complicated than it needs to be. I believe all you have to do is set the contents of your CATiledLayer to nil.

myCATiledlayer.contents = nil.

这篇关于更改图像时清除CATiledLayers缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆