如何在MKmap视图上拖动我的注释像Google Pin Drop and Draging:iOS

Rah*_*rma 5 annotations objective-c mkmapview ios

我需要一些帮助.如何在MKMapview中将注释(地图图钉)从一个点拖动到另一个点.在地图上的图钉下拉后,添加过程非常好,我想拖动该图钉(注释)并像Google地图一样更改该位置.

快乐的编码

Bha*_*ani 7

首先允许引脚拖动

- (MKAnnotationView *) mapView: (MKMapView *) mapView viewForAnnotation: (id) annotation 
{ 
    pin.draggable = YES; 
}

- (void)mapView:(MKMapView *)mapView
 annotationView:(MKAnnotationView *)annotationView
didChangeDragState:(MKAnnotationViewDragState)newState
   fromOldState:(MKAnnotationViewDragState)oldState
{
    if (newState == MKAnnotationViewDragStateEnding)
    {
        CLLocationCoordinate2D droppedAt = annotationView.annotation.coordinate;
        [annotationView.annotation setCoordinate:droppedAt];
         if(DEBUG_MODE){
        NSLog(@"Pin dropped at %f,%f", droppedAt.latitude, droppedAt.longitude);
         }
    }

}
Run Code Online (Sandbox Code Playgroud)