且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Swift中的MapKit,第2部分

更新时间:2023-11-20 23:06:04

calloutAccessoryControlTapped 委托方法必须命名为 mapView(annotationView:calloutAccessoryControlTapped :)

The calloutAccessoryControlTapped delegate method must be named mapView(annotationView:calloutAccessoryControlTapped:).

您不能使用自己的名字,如 pinPressed(...)

You can't use your own name like pinPressed(...).

这适用于任何委托方法,并由协议规定。

This applies to any delegate method and is dictated by the protocol.

所以它应该be:

func mapView(mapView: MKMapView!, annotationView: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {

    if control == annotationView.rightCalloutAccessoryView {
        println("Disclosure Pressed!")
    }
}