UIScrollView callbacks while animating internally

给你一囗甜甜゛ 提交于 2021-02-07 20:32:20

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/6489560/uiscrollview-callbacks-while-animating-internally

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!