且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

(iPhone)如何使用OS 4.0 MapKit实现可拖动的引脚?

更新时间:2023-01-27 07:46:20

当然可以哥们(是的,我在跟自己说话),

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

在自定义注释中添加:

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

这满足了实现setCoordinate的要求,如http://developer.apple.com/iphone中所述/library/documentation/MapKit/Reference/MKAnnotationView_Class/Reference/Reference.html#// apple_ref / occ / instp / MKAnnotationView / draggable

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

在MapView委托中添加:

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
}

并且在您的AnnotationView集中可拖动为true,例如:

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.