I have a problem with a CATiledLayer. It is working perfect in on iOS 4, but has problems on iOS 5.
My Problem ist that drawRect
is called twice for the same rect from two different threads at the same time. Since I load images in this call, it causes the view to load very slow.
2011-10-18 14:07:18.802 APP[12436:19003] drawRect:{{0, 400}, {368, 400}} (view:<TiledScrollColumn: 0x91bc880; frame = (0 1600; 368 5400); userInteractionEnabled = NO; layer = <CATiledLayer: 0x919c1b0>>)
2011-10-18 14:07:18.805 APP[12436:1b103] drawRect:{{0, 400}, {368, 400}} (view:<TiledScrollColumn: 0x91bc880; frame = (0 1600; 368 5400); userInteractionEnabled = NO; layer = <CATiledLayer: 0x919c1b0>>)
Has anyone an idea what could cause that or what I could do to fix that? I'm not doing special stuff with the view, it's based on the photoscroller example.
Bastian
I found a workaround. Create a serial (only one operation at at time) dispatch queue and perform all your drawing inside it, then cache the result.
I've attached the code I'm using, note I'm using a subclass of
CATiledLayer
, rather than drawing it through a delegate or other techniques.I'm also creating an indefinite tile cache, which may cause memory issues depending on your situation. You may need to manage the number of tiles in the cache, deleting old ones as new ones are added. The cache should also be cleared when a low memory warning is received. If anyone adds these improvements, please feel free to edit my answer to include it.