Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

marndt

macrumors member
Original poster
May 23, 2009
48
0
Germany
Hi folks,

I completely lost... :confused:

In my app I use a UIView backed by a CATiledLayer in a UIScrollView to implement infinite zooming: Works pretty well, when zooming in the tiles are redrawn using Core Graphics in the background, and updated to provide sharp content.

When I change some underlying data and the view must be redrawn, I trigger [view setNeedsDisplay], and the tiles are updated (unfortunately all tiles, but that seems to be a flaw in the CATiledLayer's design). But here comes the problem: Before each tile is redrawn, the complete view is turning blank, causing a kind of one-time flicker.

If I change the layer's class to CALayer, new content just replaces old one with a much smoother effect, so my drawRect: method is not causing the problem.

How do I implement a CATiledLayer which doesn't blank all tiles before redrawing them after a [view setNeedsDisplay]? Or what can I do to avoid at least the impact (e. g. creating my own backing layer behind the CATiledLayer)?

Mattes
 

marndt

macrumors member
Original poster
May 23, 2009
48
0
Germany
Just a quick reply in case sb's facing the same problem:

I was able to reproduce the effect with a completely stripped-down app: A CATiledLayer backed view erases all tiles before drawing them when [view setNeedsDisplay] is sent.

The following approach gives a much smoother user experiance: I added an empty UIView to the UIScrollView, as one view is required for a zoomable scrollview. Then I added two identical instances of my CATileLayered view to this dummy. When an update is needed I trigger the front view immediately, and the back view with a slight delay. As long as updates don't come too often, the back view is already rendered and gives a smooth transition...
 

frankus

macrumors newbie
Mar 16, 2012
2
0
I ran into this problem as well. The good news is that I've found a fix, and open-sourced it here:

https://github.com/frankus/NetPhotoScroller

The bad news is that it's not app-store approvable, because it uses a couple of undocumented methods on CATiledLayer (-canDrawRect:levelOfDetail: and -setNeedsDisplay:levelOfDetail:).

I filed a radar on this a few months ago. Fortunately it's the sort of thing they could just flip over to published status and have it work from iOS 2.0 forward.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.