MKMapKitDidChange areaAnimated stops after clicking a custom leader

I implement a custom MKAnnotationView callout with the code described here (Jacob one), which actually places another custom AnnotationView when selecting an annotation:

MKAnnotationView - block user annotation view for binding location updates

Everything works fine, but I have strange behavior. After selecting a custom leader, she will reject the leader, but the regionDidChangeAnimated delegate method will stop receiving the call after that.

Am I missing something? I can copy the map as usual, but this delegation method will not. Although, if you make an increase or decrease, it causes.

Prior to adding a custom CallOut for the AnnotationView that I post, this never happened.

thanks in advance.

Regards, Alan //

+6
source share
1 answer

I downloaded the Xcode project from the link you provided and was able to reproduce the error. The following answer is a workaround that worked for me

MKMapView Do Not Call AreaDidChangeAnimated on Pan

For convenience, I want to repeat the solution and how I applied it in the mentioned project

In CustomCalloutViewController.h add UIGestureRecognizerDelegate

 @interface CustomCalloutViewController : UIViewController <MKMapViewDelegate, UIGestureRecognizerDelegate> 

In CustomCalloutViewController.m the method viewDidLoad added before [super viewDidLoad];

 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]; } 

Then, still in CustomCalloutViewController.m add the following

 #pragma mark - #pragma mark Gesture Recognizers - (void)pinchGestureCaptured:(UIPinchGestureRecognizer*)gesture{ if(UIGestureRecognizerStateEnded == gesture.state){ ///////////////////[self doWhatYouWouldDoInRegionDidChangeAnimated]; } } - (void)panGestureCaptured:(UIPanGestureRecognizer*)gesture{ if(UIGestureRecognizerStateEnded == gesture.state){ NSLog(@"panGestureCaptured ended"); // *************** Here it is ********************* ///////////////////[self doWhatYouWouldDoInRegionDidChangeAnimated]; // *************** Here it is ********************* } } -(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{ return YES; } -(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch: (UITouch *)touch{ return YES; } 

Edit: I found another workaround here (all the bottom workarounds mentioned above). I have not tried it, but it sounds promising. I repeat it here:

My workaround is simple: in your view controller, create MKMapView in viewDidAppear :, and destroy it in viewDidDisappear :. I understand that this is not a friendly workaround for those using the Builder interface, but, in my opinion, this is the cleanest and probably the best way to save memory in your application.

+2
source

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


All Articles