0
我在地圖上添加了註釋並添加了標題,leftCalloutAccessoryView(ImageView)和rightCalloutAccessoryView(UIButton),當點擊按鈕播放音頻時,我不想點擊按鈕,當我將標註在任何開始播放音頻的區域。如何使整個調用可打開?
func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {
var annotationView = mapView.dequeueReusableAnnotationViewWithIdentifier("AnnotationImage")
if annotationView == nil {
if annotation.isKindOfClass(Annotation) {
annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: "AnnotationImage")
annotationView?.rightCalloutAccessoryView = self.playButton() // Custome button for rightCallOut.
annotationView?.leftCalloutAccessoryView = UIImageView(image: UIImage(named: "annotationPinImage"))
annotationView?.image = UIImage(named: "annotationPinImage.pdf")
annotationView?.canShowCallout = true
annotationView?.userInteractionEnabled = true
} else {
annotationView?.annotation = annotation
}
return annotationView
}
//播放按鈕的方法:
func playButton() -> UIButton {
let image: UIImage = UIImage(named: "BtnPlayAudio.pdf")!
let button: UIButton = UIButton(type: .Custom)
button.frame = CGRectMake(0, 0, image.size.width, image.size.height)
button.setImage(image, forState: .Normal)
return button
}
在此先感謝。
它的工作,但有一個問題。當我在顯示標註之前點擊註解時,此方法也在調用。 –
看@「發件人」,也許你可以根據這個來確定要撥打哪個電話。 – user3069232
或更好的嘗試使用長按來代替水龍頭。 – user3069232