I'm not sure what I'm doing wrong or failing to do, but I can't get a map pin 
annotation to drag.  Instead I'm dragging the entire map.

Pin is created and placed on a map using this code:

            mapPin = MKPointAnnotation()
            if let pin = mapPin {
                pin.coordinate = location;
                pin.title = "location"
                mapView.addAnnotation(pin)
            }

This MKMapViewDelegate function is called to create the annotationView

    func mapView(_ mapView: MKMapView,
                 viewFor annotation: MKAnnotation) -> MKAnnotationView? {

        let identifier = "pinAnnotation"
        var annotationView = 
mapView.dequeueReusableAnnotationView(withIdentifier: identifier) as? 
MKPinAnnotationView
        if (annotationView == nil) {
            annotationView = MKPinAnnotationView(annotation: annotation,
                                                 reuseIdentifier: identifier)
            if let av = annotationView {
                av.pinColor = .red;
                av.animatesDrop = false
                av.canShowCallout = false
                av.isDraggable = true
            } else {
                unexpected(error: nil, "Can't create MKPinAnnotationView")
            }
        } else {
            annotationView!.annotation = annotation
        }
        return annotationView
    }

However, a breakpoint on the the delegate function that should be called 
durring a drag operations is never triggered.

    // A pin is being dragged.
    func mapView(_ mapView: MKMapView,
                 annotationView view: MKAnnotationView,
                 didChange newState: MKAnnotationViewDragState,
                 fromOldState oldState: MKAnnotationViewDragState) {
                // ...
        }
        
What did I forget?

High Sierra (10.13)
Xcode 9.0.1 (9A1004)
I'm attempting to drag using a three finger gesture on a tablet.
                
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to