views:

714

answers:

1

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.

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

+3  A: 

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.
zPesk
Right in the soca it warns that modifying a CATiledLayers contents will effectively turn it into a regular CALayer and sure enough it does. An Apple employee did however tell me a trick: if you call setNeedsDisplay on the recently-converted-back-to-CALayer-CATiledLayer then it will *magically* turn back into a CATiledLayer.
uprise
Tyne first lone should read: "Right in the docs..."
uprise