内部动画时的UIScrollView回调 [英] UIScrollView callbacks while animating internally

查看:59
本文介绍了内部动画时的UIScrollView回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有UIScrollView,其中一个被缩放的孩子(在viewForZoomingInScrollView:scrollView中返回),还有多个其他孩子,它们注释了缩放视图,并且应始终位于相对坐标的缩放视图顶部

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

我将UIScrollView子类化,并覆盖了scrollViewDidZoom:.我将注解子项定位为

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);
}

只要用户与滚动视图进行交互,此方法就可以正常工作. scrollViewDidZoom:/scrollViewDidScroll :,但是,似乎何时不被调用

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

  • zoomBounce:scrollview比minZoom缩小,用户松开手指,scrollview动画返回minScale. scrollViewDidZoom:在动画完成时调用,而不是在动画完成时调用.

  • 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.

使用zoomToRect:animated:缩放到矩形时.同样,直到动画完成后才调用scrollViewDidZoom:.

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

所以问题归结为:每当self.zoomScale发生变化时,包括通过内部动画发生这种情况时,如何通知我?

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

或者,我可以将注释视图作为子视图添加到zoomView中,并以某种方式确保它们未缩放吗?

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.

这篇关于内部动画时的UIScrollView回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆