calloutAccessoryControlTabbed delegate does not get called

旧巷老猫 提交于 2019-12-10 12:18:42

问题


It doesn't give me any errors or warnings as well. I don't know what other relevant info or details I can provide. Please tell me if it's not enough.

  • _mapView.delegate is set to self

Method in wich the calloutAccessoryControl is set:

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {

NSLog(@"Enter viewForAnnotation delegate");

static NSString *identifier = @"MyLocation";
if ([annotation isKindOfClass:[MapViewAnnotation class]]) {

    MKPinAnnotationView *annotationView = (MKPinAnnotationView *) [_mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
    if (annotationView == nil) {
        annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
    } else {
        annotationView.annotation = annotation;
    }

    annotationView.enabled = YES;
    annotationView.canShowCallout = YES;

    UIImageView *callOutButtonImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"arrow.png"]];
    annotationView.rightCalloutAccessoryView = callOutButtonImage;

    annotationView.image=[UIImage imageNamed:@"green-node.png"];

    return annotationView;
}

return nil;

}

calloutAccessoryControlTabbed:

-(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control{
    NSLog(@"Control Tabbed!");
    _scrollView.hidden = false;
}

回答1:


The following is from the mapView:annotationView:calloutAccessoryControlTapped: discussion in the MKMapViewDelegate protocol reference document:

Accessory views contain custom content and are positioned on either side of the annotation title text. If a view you specify is a descendant of the UIControl class, the map view calls this method as a convenience whenever the user taps your view. You can use this method to respond to taps and perform any actions associated with that control. For example, if your control displayed additional information about the annotation, you could use this method to present a modal panel with that information.

I can see that you've added a UIImage to your annotation view's right callout accessory view. A UIImage object does not inherit from UIControl. A UIButton object would work.



来源:https://stackoverflow.com/questions/13381373/calloutaccessorycontroltabbed-delegate-does-not-get-called

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!