This is frustrating me!!!
It will be called most of the time but then it stops responding to the pinches. It will be called on a screen rotate and a double tap. Not to a pinch!
Help!
This is frustrating me!!!
It will be called most of the time but then it stops responding to the pinches. It will be called on a screen rotate and a double tap. Not to a pinch!
Help!
I was working on some code that had the same issue and turns out the problem was a subview with a UIGestureRecognizer
had been added as a subview to MKMapView
, and sometimes, they would cause some delegate methods not to fire.
So make sure you aren't adding subviews or anything to the MKMapView
.
Hope this helps.
I was moving the map in code and then it appears I needed to call
[mapView setNeedsDisplay];
After!
I think this problem may have something to do with multi-threading.
I had the same problem this morning. I use a gesture recognizer to capture long press event and then add a pin to the mapview. If works well but after a few rounds, the region did change method stop being called.
I tried a few solutions here but none works. Then I recalled some other issue I had before with multi-threading nature of actions. So I try to moved the code that controls the mapview in long press action to a block that runs in main thread. And the problem is solved.
I managed to solve this problem by disabling the gesture recognizer within the touchesBeganCallback
self.tapInterceptor.touchesBeganCallback = ^(NSSet *touches, UIEvent *event) {
self.tapInterceptor.enabled = NO;
// do something
};
and reenabling it in the regionDidChangeAnimated delegate method
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated {
self.tapInterceptor.enabled = YES;
// do something
}
Whenever a tap gesture recognizer added to the mapview, setting
recognizer.cancelsTouchesInView = NO;
takes care of the problem if your business logic allows for double processing if touches on mapview (by MKMapView AND the gesture recognizer that was most recently interfering with the region[Will,Did]ChangeAnimated:)