(iPhone)如何使用OS 4.0 MapKit实现可拖动的引脚? [英] (iPhone) how to implement draggable pins using OS 4.0 MapKit?
问题描述
任何人都可以使用MapKit框架提供在OS 4.0中实现可拖动引脚的任何示例代码/指令吗?
Can anyone provide any sample code/instructions for implementing draggable pins in OS 4.0 using the MapKit framework?
推荐答案
当然可以哥们(是的,我在跟自己说话),
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.
这篇关于(iPhone)如何使用OS 4.0 MapKit实现可拖动的引脚?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!