任何人都可以使用MapKit框架提供在OS 4.0中实现可拖动引脚的任何示例代码/指令吗?
答案 0 :(得分:14)
肯定是伙计(是的,我在跟自己说话),
在自定义注释中添加:
@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集中可拖动为true,例如:
customAnnotationView.draggable = YES;
我认为这就是我为使其发挥作用所做的一切。告诉我你是否有麻烦。
答案 1 :(得分:1)
查看Ching-Lang Huang的MapKitDragAndDrop和作者随附的blog post。