开发者

UIScrollView callbacks while animating internally

I have UIScrollView with one child that is zoomed (returned in viewForZoomingInScrollView:scrollView) and a number of other children which annotate the zoomed view and should always be positioned on top of the zoomed view at relative coordinates

UIScrollView
    - zoomChild (size 100x100 at scale 1)
    - Annotate Child (size 10x10), always placed at relative position (0.2, 0.2) of zoomChild's frame

I've subclassed UIScrollView and overridden scrollViewDidZoom:. I position an annotation child like

- (void)scrollViewDidZoom:(UIScrollView *)scrollView 
{
    self.annotateChild.frame = CGRectMake(0.2*100*self.zoomScale, 0.2*100开发者_如何学编程*self.zoomScale, 10, 10);
}

This works fine as long as the user is interacting with the scrollview. scrollViewDidZoom:/scrollViewDidScroll:, however, seems not to be called when

  • zoomBounce: scrollview is pinched smaller than minZoom, user releases his finger and scrollview animates back to minScale. scrollViewDidZoom: is called when the animation is complete, but not during.

  • When zooming to a rect using zoomToRect:animated:. Again, scrollViewDidZoom: is not called until animation has completed.

So the question boils down to: how can I get notified whenever self.zoomScale changes, including when this happens via some internal animation?

Alternatively, can I add my annotation views as subviews to the zoomView and somehow make sure that they are not scaled?


Here is an answer that might work: In iOS 4.0, why does UIScrollView zoomToRect:animated: not trigger the scrollViewDidScroll or scrollViewDidZoom delegates while animating?

I need to do the same as you, but I didn't get to try it out yet.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜