As already mentioned, in order for the annotation to be draggable, it must implement the method setCoordinate:.
, iOS 7 mapView:annotationView:didChangeDragState: (. Draggable Pin iOS MapKit (MKAnnotationView) ).
setCoordinate: , coordinate ( ) ( getter setter ).
( : MKPointAnnotation, , coordinate.)
NavigationAnnotation , theCoordinate setCoordinate: ( getter):
-(void)setCoordinate:(CLLocationCoordinate2D)newCoordinate
{
self.theCoordinate = newCoordinate;
}
didChangeDragState: , ( , viewForAnnotation), , . , . :
- (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;
}
}