MapView Annotation not dragging

后端 未结 4 1696
渐次进展
渐次进展 2021-01-13 13:46

I am trying to implement a draggable \"pin\" (actually a custom icon) in a map view. This is the delegate code that I have:

  -(MKAnnotationView *) mapView:(         


        
4条回答
  •  萌比男神i
    2021-01-13 14:23

    Use MKPinAnnotationView instead of MKAnnotationView.

    MKPinAnnotationView *pin = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"purple_pin"];
    if (pin==nil)
    {
        pin = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"purple_pin"];} else {
        pin.annotation=annotation;
    } 
    pin.pinColor = MKPinAnnotationColorPurple;
    pin.draggable = TRUE;
    return pin;
    

提交回复
热议问题