【发布时间】:2014-03-31 04:15:55
【问题描述】:
目前我正在实施一项功能,用户可以手动更正地图上的图钉。我已将 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);
}
}
【问题讨论】:
-
你可以尝试设置 annotationView.draggable = NO;在 if 语句中
-
如何更新注释坐标?在您提供的代码中,您不会对新坐标做任何事情。
-
@DeanDavids 您不必更新注释坐标。拖动的行为为您做到了这一点。 (很明显,如果你想更新你的模型,那么就这样做,但是注释本身会为你更新。)
标签: ios ios7 mkmapview mkannotationview