Reputation: 553
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 ?
Upvotes: 0
Views: 695
Reputation: 524
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;
}
}
Upvotes: 0
Reputation: 553
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;
}
}
Upvotes: 2