calloutAccessoryControlTabbed委托不会被调用 [英] calloutAccessoryControlTabbed delegate does not get called

查看:97
本文介绍了calloutAccessoryControlTabbed委托不会被调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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设置为self

设置calloutAccessoryControl的方法:

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:

calloutAccessoryControlTabbed:

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


推荐答案

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

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

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

我可以看到您已经在注释视图的右侧标注附件视图中添加了UIImage。 UIImage对象不从UIControl继承。 UIButton对象可以工作。

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.

这篇关于calloutAccessoryControlTabbed委托不会被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆