简体   繁体   中英

Add gesture recognizer to MKPointAnnotation

I'm junior in 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. So, I've a map, which is present via MKPointAnnotation and I've one or more geomarks, which are present via 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:

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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