calloutAccessoryControlTabbed委托不会被调用

时间:2012-11-14 15:03:38

标签: objective-c ios ios6

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

  • _mapView.delegate设置为self

设置calloutAccessoryControl的方法:

- (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 个答案:

答案 0 :(得分:2)

以下内容来自MKMapViewDelegate协议参考文档中的mapView:annotationView:calloutAccessoryControlTapped:讨论:

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

我可以看到你已经在你的注释视图正确的标注配件视图中添加了一个UIImage。 UIImage对象不从UIControl继承。 UIButton对象可以工作。

相关问题