I have added annotation on map and added title, leftCalloutAccessoryView (ImageView), and rightCalloutAccessoryView (UIButton), When tap on button it plays audio, I want instead of tapping on button when i will top on callout any area it starts playing audio.
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
}
// Play Button methods:
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
}
Thanks in advance.