【发布时间】:2010-03-25 07:55:21
【问题描述】:
我使用 CATiledLayer 作为 UIScrollView 的内容,但似乎我无法从 CATiledLayer 的委托方法中获得正确的(有时)[scrollView contentSize] 和 [scrollView contentOffset]:
- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
我知道 CATiledLayer 使用这种方法在后台线程中渲染图块。我需要使用 contentSize 和 contentOffset 来计算一些数据(一些坐标)。该应用程序在模拟器上运行良好,但在设备上,有时会得到错误的 contentSize 和 contentOffset
【问题讨论】:
-
设备上的 contentSize/Offset 值有多远?四舍五入或整个单位的问题?你不能将你知道的 contentSize 传递给包含 drawLayer:inContext: 方法的委托吗?在滚动/缩放时它不应该改变,否则你的瓷砖需要重绘。 - 这当然不是你问题的答案。
-
哇,这个问题已经一岁了。我想你现在已经想通了。干杯。
标签: iphone objective-c uiscrollview core-animation