tags:

views:

45

answers:

2

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;
}
+1  A: 

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

Look a the "draggable" property in MKAnnotationView.

Greensource
I tried using the MKPinAnnotationView right after I asked the question, but still could not get that to work. I think I am missing something because XCode gives a warning that MKPinAnnotationView doesn't implement the MKAnnotation protocol. See edit above
Derrick
+1  A: 

Here ya go: http://stackoverflow.com/questions/3191728/iphone-how-to-implement-draggable-pins-using-os-4-0-mapkit

Tristan
Thanks I hadn't had the setCoordinate method implemented.
Derrick