objective-c - 详细信息披露按钮未出现在 Mapkit 标注上

标签 objective-c ios mapkit mkannotation

我不确定为什么详细信息披露按钮没有出现在 Mapkit 标注上。这是我的代码:

我确保包含在 .h 文件中 然后是下面的方法。标注有效并在 map 加载后立即显示。我还确保在 Xib 文件中连接委托(delegate)。

   - (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation
{
    MKPinAnnotationView *mapPin = nil;
    if(annotation != map.userLocation) 
    {
        static NSString *defaultPinID = @"defaultPin";
        mapPin = (MKPinAnnotationView *)[map dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
        if (mapPin == nil )
        {
            mapPin = [[MKPinAnnotationView alloc] initWithAnnotation:annotation 
                                                     reuseIdentifier:defaultPinID];
            mapPin.canShowCallout = YES;

            UIButton *disclosureButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
            [disclosureButton addTarget:self action:@selector(clDetails:) forControlEvents:UIControlEventTouchUpInside];

            mapPin.rightCalloutAccessoryView = disclosureButton;

        }
        else
            mapPin.annotation = annotation;

    }
    return mapPin;
}




  - (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views
{
    id<MKAnnotation> myAnnotation = [self.mapView.annotations objectAtIndex:0];
    [self.mapView selectAnnotation:myAnnotation animated:YES];
}

感谢您的帮助。

最佳答案

我在 viewDidLoad 中有这行代码,它抛出了 MKAnnotation 方法。

mapView = [[MKMapView alloc]initWithFrame:self.view.bounds];

:)

关于objective-c - 详细信息披露按钮未出现在 Mapkit 标注上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12247141/

相关文章:

ios - 在 UITableViewCell 上滑动时如何配置阈值/距离

swift - 如何始终显示注释?

javascript - 如何在plugin.xml中添加同名不同文件夹的资源?

ios - iOS SDK 是否支持 SVG 作为自定义字体?

objective-c - NSTableView错误-[__NSCFConstantString setFrame :]

ios - 在iOS Obj-C中何处添加Firebase数据库引用

iphone - MapKit 不显示当前位置的蓝点

ios - 更改 View 后 MKMapView 重置

objective-c - CALayer阴影性能

objective-c - 在 Xcode 中分配基本数学运算结果时出现 "initializer element is not a compile-time constant"