简体   繁体   English

将手势识别器添加到MKPointAnnotation

[英]Add gesture recognizer to MKPointAnnotation

I'm junior in Objective-C. 我是Objective-C的大三学生。 I've a task to add gesture recognizer to MKPointAnnotation.I've heard it's possible to do via MKMapView delegate.But I didn't understand it yet. 我有一个向MKPointAnnotation添加手势识别器的任务。我听说可以通过MKMapView委托来做,但是我还不了解。 So, I've a map, which is present via MKPointAnnotation and I've one or more geomarks, which are present via MKPointAnnotation. 因此,我有一张地图,该地图通过MKPointAnnotation显示,我有一个或多个地理标记,这些地图通过MKPointAnnotation显示。 How to decide this task? 如何决定这项任务? My code example: 我的代码示例:

MKPointAnnotation *newPinAnnotation = [[MKPointAnnotation alloc]init];
CLLocationCoordinate2D pinCoordinate;
pinCoordinate.latitude = self.userLocation.coordinate.latitude;
pinCoordinate.longitude = self.userLocation.coordinate.longitude;
newPinAnnotation.coordinate = pinCoordinate;
[self.mapView addAnnotation:newPinAnnotation];

I don't understand completely, which action you would like to implement. 我不完全了解您要执行哪种操作。 But I think that it will help you. 但我认为这会对您有所帮助。 You should implement one or both of these MKMapViewDelegate methods: 您应该实现以下一个或两个MKMapViewDelegate方法:

- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view;

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view didChangeDragState:(MKAnnotationViewDragState)newState 
   fromOldState:(MKAnnotationViewDragState)oldState

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM