Dragging the map after dragging my MKAnnotationView does not move the MKAnnotationView with it

荒凉一梦 提交于 2019-12-04 03:14:42
gmm

I had the same problem and I solved it adding "setDragState" to my MKAnnotationView class.

This is an old solution but it worked to me (iOS8).

Just set the annotationView.dragState to MKAnnotationViewDragStateNone after ending the drag:

    - (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view didChangeDragState:(MKAnnotationViewDragState)newState fromOldState:(MKAnnotationViewDragState)oldState {
        if ([view.annotation isKindOfClass:[PinAnnotation class]]) {
            if (newState == MKAnnotationViewDragStateEnding) {
                view.dragState = MKAnnotationViewDragStateNone;
            }
        }
    }

Don't reuse MKAnnotationView and it will work.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!