Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

detecting which accessory view is tapped in calloutAccessoryControlTapped delegate

I would like to detect if the rightCalloutAccessoryView has been tapped via the delegate method below, how can I do that?

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)contro
like image 203
aherlambang Avatar asked Dec 18 '25 17:12

aherlambang


1 Answers

calloutAccessoryControlTapped method will be triggered for the tap action on both leftCalloutAccessoryView and rightCalloutAccessoryView. To distinguish the accessory views, you can set tag for both the accessory views while you create them. And in your calloutAccessoryControlTapped method, you can check the tag value and do the respective action depending on the tag value.

For example, consider you have set 1 and 2 for the tags of your left and right accessory view respectively. Then your calloutAccessoryControlTapped method will look something like the following,

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {

    if ([control tag] == 1) {

        // Left Accessory Button Tapped

    } else if ([control tag] == 2) {

        // "Right Accessory Button Tapped
    }
}
like image 148
EmptyStack Avatar answered Dec 21 '25 07:12

EmptyStack



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!