开发者

(iPhone) how to implement draggable pins using OS 4.0 MapKit?

开发者 https://www.devze.com 2023-01-06 17:49 出处:网络
Can anyone provide any sample c开发者_运维百科ode/instructions for implementing draggable pins in OS 4.0 using the MapKit framework?Sure thing buddy (yes I\'m talking to myself),

Can anyone provide any sample c开发者_运维百科ode/instructions for implementing draggable pins in OS 4.0 using the MapKit framework?


Sure thing buddy (yes I'm talking to myself),

In your custom annotation add:

@property (nonatomic, readwrite, assign) CLLocationCoordinate2D coordinate; 

This satisfies the requirement of implementing setCoordinate, as mentioned inhttp://developer.apple.com/iphone/library/documentation/MapKit/Reference/MKAnnotationView_Class/Reference/Reference.html#//apple_ref/occ/instp/MKAnnotationView/draggable

In your MapView delegate add:

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)annotationView didChangeDragState:(MKAnnotationViewDragState)newState fromOldState:(MKAnnotationViewDragState)oldState 
{
//..Whatever you want to happen when the dragging starts or stops
}

and in your AnnotationView set draggable to true, so for example:

customAnnotationView.draggable      = YES;

I think that was everything that I did to get it working. Tell me if you have troubles.


Check out MapKitDragAndDrop by Ching-Lang Huang and the author's accompanying blog post.

0

精彩评论

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

关注公众号