0

I have a problem with my map after an annotation view is dragged: when I change the region panning the map, the dragged annotation remains fixed in the screen ( other annotation that have not been dragged are displayed correctly, the problem is on every annotation view that is dragged ; note that the annotation view continues to bel selectable for callout and dragging, the only problem that i can see is that it does not move when I pan Map )

I there any solution ? is this a known bug with ios 7.1 ? Or am i missing something in my code ?

atrebbi
  • 553
  • 3
  • 20
  • Can you post the code for how you're adding annotations? – Aaron Bratcher Mar 26 '14 at 12:09
  • a video to explain: http://youtu.be/B49NanaTXL0 – atrebbi Mar 26 '14 at 12:10
  • the annotation are simply added to map with addAnnotation: MyMapAnnotation *imagePM = ( MyMapAnnotation *) annotation; MyMapAnnotation *pin = (MyMapAnnotation*)[_delegate getAnnotation:self]; pin = [pin init]; pin.image = imagePM.image; [pin setCoordinate:imagePM.coordinate]; [pin setTitle:imagePM.title]; [pin setSubtitle:imagePM.subtitle]; pin.identifier = imagePM.identifier; [_mapView addAnnotation:pin]; – atrebbi Mar 26 '14 at 12:16
  • See http://stackoverflow.com/questions/21567082/ios-mapkit-dragged-annotations-mkannotationview-no-longer-pan-with-map –  Mar 26 '14 at 12:20
  • thx, seems solved, doing manually do the transition to MKAnnotationViewDragStateNone ; i post the cose in the answer for future ref – atrebbi Mar 26 '14 at 12:35

2 Answers2

2

seems the code should care to do last transition to reset annotation view , this fixes the problem :

-(void)setDragState:(MKAnnotationViewDragState)dragState animated:(BOOL)animated {
    [super setDragState:dragState animated:animated];
    if (dragState==MKAnnotationViewDragStateStarting) {
        [...
    } else if (dragState==MKAnnotationViewDragStateEnding || dragState==MKAnnotationViewDragStateCanceling) {
        ...
        self.dragState = MKAnnotationViewDragStateNone;
    }
}
Aaron Bratcher
  • 6,051
  • 2
  • 39
  • 70
atrebbi
  • 553
  • 3
  • 20
0

If annotation is dragged then you have to set its drag state to none in its delegate method. This code solved my problem

    - (void)mapView:(MKMapView *)mapView
     annotationView:(MKAnnotationView *)annotationView
    didChangeDragState:(MKAnnotationViewDragState)newState
       fromOldState:(MKAnnotationViewDragState)oldState
{
if (newState == MKAnnotationViewDragStateEnding)
    {
     ..... your code.....
    annotationView.dragState=MKAnnotationViewDragStateNone;
    }

}
Smart guy
  • 494
  • 6
  • 9