Re: MKMapView pin dragging question
Re: MKMapView pin dragging question
- Subject: Re: MKMapView pin dragging question
- From: Alex Zavatone <email@hidden>
- Date: Wed, 25 Oct 2017 20:11:14 -0500
This might be simple. Please correct me if I am wrong, I think the last time I
dealt with this was in 2012.
Isn’t there a method or property such as canDragPin that you have to override
or implement in your subclass?
> On Oct 25, 2017, at 8:08 PM, Marco S Hyman <email@hidden> wrote:
>
> 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 (email@hidden)
>
> 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:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden