Rah*_*rma 5 annotations objective-c mkmapview ios
我需要一些帮助.如何在MKMapview中将注释(地图图钉)从一个点拖动到另一个点.在地图上的图钉下拉后,添加过程非常好,我想拖动该图钉(注释)并像Google地图一样更改该位置.
快乐的编码
首先允许引脚拖动
- (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)
| 归档时间: |
|
| 查看次数: |
1059 次 |
| 最近记录: |