3
votes

I'm trying to recreate the double tap to zoom in and two finger tap to zoom out on a map, and I'm having some weird animation slowness specifically when I two finger tap to zoom out. (I have to do this because I'm anchoring the center point on zooming, which is not possible with the default double tap and two finger tap gestures)

When I'm at a close zoom level it's not a problem, but once I get to a city zoom level and farther out, the animation takes an extremely long time. If I set animated to NO on setRegion it jumps to the zoom level I want without delay, which leads me to believe there's no trouble loading the bigger region.

In viewDidLoad I set zoomEnabled = NO and add a two finger tap gesture recognizer and double tap gesture recognizers. (double tap gesture recognizer has the same problem)

My two finger tap code is simply this:

- (void)mapTwoFingerTapped:(UITapGestureRecognizer *)doubleFingerTapRecognizer
{
  double zoomScale = 2;
  MKCoordinateSpan span = MKCoordinateSpanMake(self.map.region.span.latitudeDelta * zoomScale,
                                             self.map.region.span.longitudeDelta * zoomScale);

  [self.map setRegion:MKCoordinateRegionMake(self.map.region.center, span) animated:YES];
}

Which means all I do is double the latitude and longitude and set the new region. What's causing the animation to slow down and how do I bring it back to regular speed?

EDIT: I discovered this is only happening on iOS 7 devices. iOS 6 seems to be unaffected.

1

1 Answers

0
votes

Just based on some experience, it sounds like you might have an open animation block from some other part of your code which is affecting the duration of the setRegion: animation. Can you walk through some of the other code beginning with the gesture?