1
votes

I am using a CATiledLayer as content of UIScrollView, but seems I can not get the correct (sometimes) [scrollView contentSize] and [scrollView contentOffset] from CATiledLayer's delegate method :

- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx

I know CATiledLayer uses this method to render tile in a background thread. And I need to use contentSize and contentOffset to calculate some data (some coordinates). The app ran fine on simulator but on device, it sometimes got the wrong contentSize and contentOffset

1
How far off are the contentSize/Offset values on the device? A matter of rounding or whole units off? Couldn't you pass the contentSize you know to be true to the delegate containing the drawLayer:inContext: method? It shouldn't change while you're scrolling/zooming, for otherwise your tiles would need redrawing. - this is of course, not an answer to your question. - epologee
Wow this question is one year old. I guess you've figured it out by now then. Cheers. - epologee

1 Answers

0
votes

CATiledLayer does not calculate these values for you, you have to set them.

note that for the tile size it does not apply contentScale. So on Retina the individual tiles are half as big as you specify.

If you still want an answer for this you have to clarify the question.