calloutAccessoryControlTabbed delegate does not ge

2019-06-13 04:05发布

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条回答
来,给爷笑一个
2楼-- · 2019-06-13 04:31

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.

查看更多
登录 后发表回答