Speckpgh
Speckpgh

Reputation: 3372

calloutAccessoryControlTapped not being called

I am trying to use the CalloutAccessory feature, but the delegate method never gets called. I have the delegate properly set up as other mapview delegate methods in my code are firing fine, but for some reason for this one, the delegate method never gets called when the button is tapped.

I have tried extending RouteViewAnnotation from both the MKAnnotationView and the MKPinAnnotationView, and it makes no difference.. the delegate method never gets called.

What am I missing? Do I need something else that isn't here for this to work? The RouteAnnotationView just overrides the drawrect, and has no other code in it.

Relevant Code:

In ViewForAnnotation

- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
if([annotation isMemberOfClass:[RouteAnnotation class]])
{
    RouteAnnotationView *routeAnnotationView = [[RouteAnnotationView alloc] initWithFrame:(CGRectMake(0,0,100,50))] ;
    [routeAnnotationView setBackgroundColor:[UIColor clearColor]];
    routeAnnotationView.centerOffset = CGPointMake(0,-25);
    routeAnnotationView.canShowCallout = TRUE;
    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 100.0, 40.0)];

    [button setTitle:@"Select" forState:UIControlStateNormal];

    button.backgroundColor = [UIColor blueColor];

    [routeAnnotationView setRightCalloutAccessoryView:button];

    return routeAnnotationView;

}
.
.
.
}

In calloutAccssoryControlTapped

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
NSLog(@"CALLOUT BUTTON TOUCHED");
}

Upvotes: 1

Views: 912

Answers (1)

Speckpgh
Speckpgh

Reputation: 3372

Okay, I figured it out... I had a tapGestureRecognizer assigned to the MapView (A WildcardGestureRecognizer (https://github.com/OrbJapan/ResizableMKCircleOverlay/blob/master/MapView/WildcardGestureRecognizer.m) to be exact) added to my MapView, and while this had not interfered in any way with annotation touches, or other touches in the MapView or MapView Delegate methods I was using, for some reason this completely interfered with the calloutAccessoryControlTapped Delegate method and it was never called... once I removed this the method called without issue.

Upvotes: 2

Related Questions