MKMapView not called regionDidChangeAnimated on Pan

I have an application with MKMapView and code that is called every time the map changes places (in regionDidChangeAnimated). When the application is initially loaded, regionDidChangeAnimated is called on the panel (swipes), pinches, taps and buttons that explicitly update the map coordinates. After loading other views and returning to the map, regionDidChangeAnimated is called only for taps and buttons that explicitly update the map. Panning maps and pinches no longer causes regionDidChangeAnimated.

I looked at this https://stackoverflow.com/a/412860/ which did not solve this problem. Forum posts on devforums and iphonedevsdk do not work either. Does anyone know what causes this problem? I do not add any subzones to MKMapView.

+6
source share
1 answer

I did not want to initially do it this way, but it seems to work without problems so far (taken from devforums post):

Add a UIGestureRecognizerDelegate to your header. Now add a version number check ... If we are on iOS 4, we can do this:

if (NSFoundationVersionNumber >= 678.58){ UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinchGestureCaptured:)]; pinch.delegate = self; [mapView addGestureRecognizer:pinch]; [pinch release]; UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureCaptured:)]; pan.delegate = self; [mapView addGestureRecognizer:pan]; [pan release]; } 

Add delegate methods to handle gestures:

 #pragma mark - #pragma mark Gesture Recognizers - (void)pinchGestureCaptured:(UIPinchGestureRecognizer*)gesture{ if(UIGestureRecognizerStateEnded == gesture.state){ ///////////////////[self doWhatYouWouldDoInRegionDidChangeAnimated]; } } - (void)panGestureCaptured:(UIPanGestureRecognizer*)gesture{ if(UIGestureRecognizerStateEnded == gesture.state){ ///////////////////[self doWhatYouWouldDoInRegionDidChangeAnimated]; } } -(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{ return YES; } -(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch: (UITouch *)touch{ return YES; } - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{ return YES; } 
+3
source

Source: https://habr.com/ru/post/907527/


All Articles