iPhone – How do I detect click notes PIN on a map?

I want to detect click on the annotation pin (mapkit) so that I can perform actions on the event.

Now, if I touch the annotation pin, The default comment tag will pop up. I want to customize it to call my method when I touch the pin.

You need to implement the following delegate method

(MKAnnotationView) mapView viewForAnnotation:(id) annotation

Then declare the following in this method< /p>

MKPinAnnotationView *view=[[MKPinAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:@"abc"];
view.canShowCallout=YES;
view.calloutOffset =CGPointMake(-20,10); //As per your choice

Then you can add UI to your annotations, such as UIButton or UIImage as view.rightCalloutAccesoryView View.leftCalloutAccesoryView

div>

I want to detect click on the annotation pin (mapkit) so that I can perform actions on the event.

Now, if I touch the annotation pin, it will The default comment tag pops up. I want to customize it to call my method when the pin is touched.

You need to implement the following delegate method

(MKAnnotationView) mapView viewForAnnotation:(id) annotation

Then declare the following in this method

MKPinAnnotationView *view=[[MKPinAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier: @"abc"];
view.canShowCallout=YES;
view.calloutOffset=CGPointMake(-20,10); //As per your choice

Then you can Add UI to the annotation, such as UIButton or UIImage as view.rightCalloutAccesoryView View.leftCalloutAccesoryView

Leave a Comment

Your email address will not be published.