开发者

How to have a user-movable MKPlacemark?

I would like to emulate the 'Drop Pin' feature in the Maps app开发者_StackOverflow社区lication. 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;
}


Here ya go: (iPhone) how to implement draggable pins using OS 4.0 MapKit?


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

Look a the "draggable" property in MKAnnotationView.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜