0

I'm calculating the center point of a view using delta values calculated after scrolling, this works great when the zoom level is 1.0 but any other zoom level causes the center be incorrect. Here's my code:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {

    CGFloat dX = self.contentOffset.x - lastScrollPoint.x;
    CGFloat dY = self.contentOffset.y - lastScrollPoint.y;

    dX *= self.zoomScale;
    dY *= self.zoomScale;

    lastScrollPoint = self.contentOffset;
    viewCenter.x += dX;
    viewCenter.y += dY;
}

What do I need to do to adjust the delta for the zoom scale? I thought that multiplying by the zoomScale would be enough but it's obviously not.

Wil Shipley
  • 9,343
  • 35
  • 59
JWood
  • 2,804
  • 2
  • 39
  • 64
  • 1
    seems like a possible duplicate of - http://stackoverflow.com/questions/1316451/center-content-of-uiscrollview-when-smaller – rishi Jan 10 '12 at 17:11
  • That question is about anchoring the view in the center I believe whereas I'm looking to maintain a relationship between 2 different sets of coordinates. They start at the same point in the center but to keep them in sync I need to calculate the delta on scroll. – JWood Jan 10 '12 at 17:25

0 Answers0