I am updating my app (MyWorld) to iOS 7. One of the features of the app is that you can drag pin on the map view. It seems to be broken in iOS7.
Steps to recreate the problem:
Whenever I scroll the map view annotation is moved with the map. It seems like it's not attached to the right view or layer?? If the pin is not dragged map view seems to work fine and annotation stays in defined position. I wonder if this is a mistake on my side or a known issue?
I created a dummy MapViewTest project that ilusstrates the problem on github: https://github.com/DJMobileInc/MapViewTest
This is from the MKAnnotationView Class Reference, for the MKAnnotationViewDragStateNone constant:
MKAnnotationViewDragStateNone
The view is not involved in a drag operation. The annotation view is responsible for returning itself to this state when a drag ends or is canceled.
To fix the problem, your map view delegate will need to set the annotation view's dragState back to MKAnnotationViewDragStateNone when ever the annotation ends or cancels its drag operation.
For example:
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)annotationView
didChangeDragState:(MKAnnotationViewDragState)newState
fromOldState:(MKAnnotationViewDragState)oldState
{
if (newState == MKAnnotationViewDragStateEnding) {
// custom code when drag ends...
// tell the annotation view that the drag is done
[annotationView setDragState:MKAnnotationViewDragStateNone animated:YES];
}
else if (newState == MKAnnotationViewDragStateCanceling) {
// custom code when drag canceled...
// tell the annotation view that the drag is done
[annotationView setDragState:MKAnnotationViewDragStateNone animated:YES];
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With