Derrick
Derrick

Reputation: 2366

How to have a user-movable MKPlacemark?

I would like to emulate the 'Drop Pin' feature in the Maps application. I have a mapview in my controller that I am able to add a MKPlacemark to. It doesn't respond to user action though. Can I emulate the dropped pin with stock classes or do I need to subclass an MKAnnotation View?

EDIT2:

Here's the code I'm trying, which I think should work. It drops the pin, and I can change the color but it can't be moved.

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id
        <MKAnnotation>)annotation
{
    MKPinAnnotationView *pinView = [[MKPinAnnotationView alloc]
        initWithAnnotation:annotation reuseIdentifier:nil];
    [pinView setDraggable:YES];
    [pinView setAnimatesDrop:YES];
    [pinView setPinColor:MKPinAnnotationColorGreen];
    return pinView;
}

Upvotes: 1

Views: 1577

Answers (2)

Greensource
Greensource

Reputation: 221

With iOS 4 it's natively possible. Did you add an custom annotationView or a MKPinAnnotationView?

Look a the "draggable" property in MKAnnotationView.

Upvotes: 1

Related Questions