Ios MapKit注释如何添加详细信息披露按钮?

Ios MapKit注释如何添加详细信息披露按钮?,ios,swift,xcode,mapkitannotation,Ios,Swift,Xcode,Mapkitannotation,我将注释放在地图上,点击pin后,右侧应该有一个详细披露信息按钮,这样我可以在点击按钮后添加更多代码。但是当我运行项目时,点击pin,没有显示info按钮。任何人都可以提供代码来添加披露信息按钮 我希望右侧有一个信息按钮: 我的代码: extension ViewController: MKMapView{ func mapView(mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -> MKAnnota

我将
注释
放在地图上,点击pin后,右侧应该有一个
详细披露信息按钮
,这样我可以在点击按钮后添加更多代码。但是当我运行项目时,点击pin,没有显示
info按钮。任何人都可以提供代码来添加披露信息按钮

我希望右侧有一个信息按钮:

我的代码:

extension ViewController: MKMapView{


func mapView(mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView! {



  }

创建
MKAnnotationView
并向其添加按钮。因此:

    func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
        if annotation is MKUserLocation { return nil }

        if let annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: "") {
            annotationView.annotation = annotation
            return annotationView
        } else {
            let annotationView = MKPinAnnotationView(annotation:annotation, reuseIdentifier:"")
            annotationView.isEnabled = true
            annotationView.canShowCallout = true

            let btn = UIButton(type: .detailDisclosure)
            annotationView.rightCalloutAccessoryView = btn
            return annotationView
        }
    }

创建
MKAnnotationView
并向其添加按钮。因此:

    func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
        if annotation is MKUserLocation { return nil }

        if let annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: "") {
            annotationView.annotation = annotation
            return annotationView
        } else {
            let annotationView = MKPinAnnotationView(annotation:annotation, reuseIdentifier:"")
            annotationView.isEnabled = true
            annotationView.canShowCallout = true

            let btn = UIButton(type: .detailDisclosure)
            annotationView.rightCalloutAccessoryView = btn
            return annotationView
        }
    }

@Rob,你的意思是像这样的
if annotation.isMember(of:MKUserLocation.self){return nil}
?@Rob,更新了示例。再次感谢您的反馈@Rob,你的意思是像这样的
if annotation.isMember(of:MKUserLocation.self){return nil}
?@Rob,更新了示例。再次感谢您的反馈!