Das Ziehen der Karte nach dem Ziehen meiner MKAnnotationView verschiebt die MKAnnotationView nicht mit

In MKPinAnnotationView können Sie ein benutzerdefiniertes Bild nicht als "Stecknadel" verwenden und gleichzeitig das Ziehen aktivieren, da das Bild wieder auf die Standardstecknadel zurückgesetzt wird, sobald Sie mit dem Ziehen beginnen. Daher verwende ich eine MKAnnotationView anstelle einer MKPinAnnotationView.

Wenn Sie MKAnnotationView anstelle von MKPinAnnotationView verwenden, wird Ihr benutzerdefiniertes Bild als Pin angezeigt. Die Drag & Drop-Animation, die Sie mit dem Standard-Pin erhalten, wird jedoch nicht unterstützt.

Mein Problem ist jedoch, dass die MKAnnotationView nicht mehr mit der Karte mitbewegt wird, nachdem ich meine benutzerdefinierte MKAnnotationView an einen neuen Punkt auf der Karte gezogen und dann die Karte selbst verschoben habe.

-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {
    static NSString *defaultID = @"myLocation";

    if([self.annotation isKindOfClass:[PinAnnotation class]])
    {
        //Try to get an unused annotation, similar to uitableviewcells
        MKAnnotationView *annotationView = [self.mapView dequeueReusableAnnotationViewWithIdentifier:defaultID];

        //If one isn't available, create a new one
        if(!annotationView)
        {
            annotationView = [[MKAnnotationView alloc] initWithAnnotation:self.annotation reuseIdentifier:defaultID];
            annotationView.canShowCallout = YES;
            annotationView.draggable = YES;
            annotationView.enabled = YES;
        }
        UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, 32, 32)];
        imgView.image = self.passableTag.image;
        annotationView.leftCalloutAccessoryView = imgView;
        annotationView.image = [UIImage imageNamed:[Constants tagIconImageNameForTagType:self.passableTag.type]];
        return annotationView;
    }
    return nil;
}

Antworten auf die Frage(2)

Ihre Antwort auf die Frage