可拖动的Pin在地图上没有固定的位置

目前我正在实现一个function,用户可以在地图上手动更正一个引脚。 我已经将annotationView设置为annotationView.draggable = YES; 我也实现了委托方法来接收新的坐标。 但是现在我怎么能告诉mapView拖动动作现在应该停止,并且在地图上固定位置,即使地图被移动了。

目前的行为是,在将引脚拖动到新的位置之后,如果我然后移动地图,则引脚在设备屏幕上具有固定的位置,但不在地图上。

帮助表示赞赏:)。

代表:

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

更新:

好的,修复它:

 - (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)annotationView didChangeDragState:(MKAnnotationViewDragState)newState fromOldState:(MKAnnotationViewDragState)oldState { if (newState == MKAnnotationViewDragStateStarting) { annotationView.dragState = MKAnnotationViewDragStateDragging; } else if (newState == MKAnnotationViewDragStateEnding || newState == MKAnnotationViewDragStateCanceling) { annotationView.dragState = MKAnnotationViewDragStateNone; } } 

现在我只需要坚持新的坐标,我很好.. – 也许我会添加一些自定义animation的状态..:

当拖动状态更改为MKAnnotationViewDragStateStarting时,将状态设置为MKAnnotationViewDragStateDragging。 如果您执行animation以指示拖动的开始,并且animation参数为YES,则在更改状态之前执行该animation。

当状态更改为MKAnnotationViewDragStateCanceling或MKAnnotationViewDragStateEnding时,将状态设置为MKAnnotationViewDragStateNone。 如果在拖动结束时执行animation,并且animation参数为YES,则应在更改状态之前执行该animation。