Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/93.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS-在MKAnnotationView上设置详细信息披露按钮_Ios_Uibutton_Mapkit_Mkannotation_Mkannotationview - Fatal编程技术网

iOS-在MKAnnotationView上设置详细信息披露按钮

iOS-在MKAnnotationView上设置详细信息披露按钮,ios,uibutton,mapkit,mkannotation,mkannotationview,Ios,Uibutton,Mapkit,Mkannotation,Mkannotationview,我的MapViewController中有以下方法: - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation { MKAnnotationView *annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:@"MapVC"]; if (!annot

我的MapViewController中有以下方法:

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {
    MKAnnotationView *annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:@"MapVC"];
    if (!annotationView) {
        annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"MapVC"];
        annotationView.canShowCallout = YES;
        annotationView.leftCalloutAccessoryView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
        annotationView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        // could put a rightCalloutAccessoryView here
    } else {
        annotationView.annotation = annotation;
        [(UIImageView *)annotationView.leftCalloutAccessoryView setImage:nil];
    }

    return annotationView;
} 
-(MKAnnotationView*)地图视图:(MKMapView*)地图视图注释:(id)注释{
MKAnnotationView*annotationView=[mapView dequeueReusableAnnotationViewWithIdentifier:@“MapVC”];
如果(!annotationView){
annotationView=[[MKPinAnnotationView alloc]initWithAnnotation:annotation重用标识符:@“MapVC”];
annotationView.canShowCallout=是;
annotationView.leftCalloutAccessoryView=[[UIImageView alloc]initWithFrame:CGRectMake(0,0,30,30)];
annotationView.rightCalloutAccessoryView=[UIButton Button,类型:UIButtonTypedTailDisclosure];
//可以在这里放置右Callout AccessoryView
}否则{
annotationView.annotation=注释;
[(UIImageView*)annotationView.leftCalloutAccessoryView setImage:nil];
}
返回注释视图;
} 
我相信它的设置是正确的,但是当我的地图正确地显示带有标题和副标题的注释,但它们没有显示详细信息披露按钮时,我是否遗漏了什么


另一件事是,调试此方法时从未调用,但注释视图会显示标题和副标题。

很可能地图视图的
委托未设置

如果未设置
委托
,或者未实施
viewForAnnotation
方法,则地图视图将创建一个默认注释视图,该视图是一个带有标注的红色图钉,标注仅包含标题和副标题(除非标题为空,在这种情况下,您将获得一个图钉,但没有标注)

将地图视图的
委托
出口连接到文件的所有者,或在代码中添加此项(例如在添加注释之前在
视图加载
):

另外,如果不使用ARC,请在
alloc
行中添加
autorelease
,以避免内存泄漏

mapView.delegate = self;