Segue 不适用于地图注释按钮 - 看不出哪里出了问题

Segue doesn't work on Map Annotation Button- Can't see what is wrong

我创建了这个在地图上有固定注释的应用程序,您可以按下按钮查看该地点的其他信息,例如图片、标题和一些文本。 问题是按钮完全没有任何作用,即使我实现了 prepareforsegue 方法。

这是有问题的代码部分,这里还有一个 link 整个项目,以防示例代码不足 Map Project

 func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {
    if let annotation = annotation as? Shops{
        let identifier = "pin"
        var view: MKPinAnnotationView
        if let dequeuedView = mapView.dequeueReusableAnnotationViewWithIdentifier(identifier)
            as? MKPinAnnotationView {
                dequeuedView.annotation = annotation
                view = dequeuedView
        } else {

            view = MKPinAnnotationView(annotation: annotation, reuseIdentifier: identifier)
            view.canShowCallout = true
            view.calloutOffset = CGPoint(x: -5, y: 5)

            view.rightCalloutAccessoryView = UIButton(type: .DetailDisclosure) as UIView
        }
        return view
    }
    return nil
}

//按下按钮并继续

    func Button(mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl){
        if control == view.rightCalloutAccessoryView {

        self.performSegueWithIdentifier("ShowDetails", sender: self)
        }
    }

//到顶部 重写 func prepareForSegue(segue: UIStoryboardSegue, 发件人:AnyObject?){

MKMapViewDelegate 函数没有那个签名。

正确的是

func mapView(mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {
    if control == view.rightCalloutAccessoryView {

    self.performSegueWithIdentifier("ShowDetails", sender: self)
    }
}

您使用 Button 而不是 mapView

启动了函数