我需要帮助。如何在MKMapview中将注释( map 图钉)从一个点拖到另一个点。
在图钉上的下拉列表中添加过程都很好,我想拖动该图钉(注释)并更改该位置,就像Google map 一样。
快乐编码
最佳答案
首先让别针拖动
- (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);
}
}
}