【发布时间】:2011-03-12 15:03:41
【问题描述】:
谁能提供任何使用 MapKit 框架在 OS 4.0 中实现可拖动引脚的示例代码/说明?
【问题讨论】:
标签: iphone mapkit draggable mkmapview drag
谁能提供任何使用 MapKit 框架在 OS 4.0 中实现可拖动引脚的示例代码/说明?
【问题讨论】:
标签: iphone mapkit draggable mkmapview drag
当然,伙计(是的,我是在自言自语),
在您的自定义注释中添加:
@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 /可拖动
在您的 MapView 委托中添加:
- (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 中将 draggable 设置为 true,例如:
customAnnotationView.draggable = YES;
我认为这就是我为使其正常工作所做的一切。有问题请告诉我。
【讨论】:
查看 MapKitDragAndDrop by Ching-Lang Huang 和作者随行的 blog post。
【讨论】: