Ratka Ratka - 3 months ago 10
iOS Question

Cannot tap on annotation when animating

I've got my custom annotation. I animate it from time to time:

UIView.animateWithDuration(duration, delay: 0, options: .CurveLinear, animations: {
customAnnotation.coordinate = newCoordinate


and while this is happening I can't tap on it to call mapView:didSelectAnnotationView

I even added UIButton as a subview:

let button = UIButton(frame: CGRect(x: 7.25, y: 17, width: 37, height: 15))
let text = customAnnotation.displayedName
button.setTitle(text, forState: .Normal)
button.backgroundColor = UIColor.blackColor()
button.setTitleColor(UIColor.greenColor(), forState: .Normal)
button.addTarget(self, action: "buttonTapped:", forControlEvents: .TouchUpInside)
customAnnotationView?.addSubview(button)


in mapView:viewForAnnotation but it doesn't work either.
Any ideas?

Answer

Use below might be work for you.

 View.animateWithDuration(duration, delay: 0, options: .CurveLinear | .AllowUserInteraction , animations: {
                            customAnnotation.coordinate = newCoordinate
})
Comments