0

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

  • _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;
}

calloutAccessoryControl 选项卡:

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

1 回答 1

2

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

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

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

于 2012-11-14T15:11:30.723 回答