calloutAccessoryControlTabbed委托不会被调用

它也没有给我任何错误或警告。 我不知道我能提供的其他相关信息或细节。 如果还不够,请告诉我。

  • _mapView.delegate设置为self

设置calloutAccessoryControl的方法:

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id )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; } 

以下是来自mapView:annotationView:calloutAccessoryControlTapped:讨论在MKMapViewDelegate协议参考文档中:

附件视图包含自定义内容,并位于注释标题文本的任一侧。 如果您指定的视图是UIControl类的后代,则只要用户点击您的视图,地图视图就会调用此方法。 您可以使用此方法响应点击并执行与该控件关联的任何操作。 例如,如果控件显示有关注释的其他信息,则可以使用此方法显示包含该信息的模式面板。

我可以看到你已经在注释视图的右侧标注附件视图中添加了一个UIImage。 UIImage对象不从UIControlinheritance。 UIButton对象可以工作。