我需要一些帮助。我如何在 MKMapview 中将注释( map 图钉)从一个点拖到另一个点。 在 map 上下拉图钉后,添加过程一切顺利,我想拖动那个图钉(注释)并像谷歌地图一样改变那个地方。
快乐编码
最佳答案
首先允许pin拖动
- (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);
}
}
}
关于ios - 我如何在 MKmapView 中拖动我的注释,就像 Google Pin Drop 和 Dragging :iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36590554/