how to manage drag and drop for MKAnnotationView on IOS?

后端 未结 3 706
青春惊慌失措
青春惊慌失措 2020-12-03 17:44

I\'m working without InterfaceBuilder.

I\'ve an instance of MKAnnotationView with setDraggable on YES, In My MK

3条回答
  •  天涯浪人
    2020-12-03 18:43

    you may also want to add the following:

    if (newState == MKAnnotationViewDragStateStarting) {
        annotationView.dragState = MKAnnotationViewDragStateDragging;
    }
    else if (newState == MKAnnotationViewDragStateEnding || newState == MKAnnotationViewDragStateCanceling) {
        annotationView.dragState = MKAnnotationViewDragStateNone;
    }
    

    since MKAnnotationView doesn't change its drag state accurately (which could make your map pan with your annotation even after you stop dragging)

提交回复
热议问题