3

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?

toucan
  • 1,465
  • 1
  • 17
  • 31

1 Answers1

2

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.

Community
  • 1
  • 1
fabb
  • 11,660
  • 13
  • 67
  • 111