0

In iOS 10.1, swift 3 I have added some annotations (cars) on my Apple Map. I made them move by using animate(withDuration duration: TimeInterval, animations: @escaping () -> Void).

I want to show information when we tap on the cars, but the event mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) is not work when the cars are moving. I guess that only works when the cars don't move (I have tried).

Then I add a UITapGestureRecognizer into Map to detect tapped coordinate and check it is near by the cars' coordinate or not. That works. However, it only works when we tap near by the cars. If we tap inside the cars, it does not work.

I hope you can give me a solution for this case. Thanks a lot.

EDIT

In func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? before return a MKAnnotationView I set property isUserInteractionEnabled false. The UITapGestureRecognizer works perfectly.

But I want to know how to select Animating annotation. Do you have any solutions?

Luat Vu Dinh
  • 460
  • 6
  • 10
  • check this https://stackoverflow.com/questions/37819903/ios-layer-animation-explanation/37820225#37820225 maybe can help you – Reinier Melian Mar 02 '18 at 06:35
  • check this answer as well https://stackoverflow.com/questions/37818440/update-views-frame-while-its-being-animated/37819789#37819789 can you share your code? – Reinier Melian Mar 02 '18 at 06:39
  • Thanks @ReinierMelian. But sorry I can't share my code. I'll see that when I have time. – Luat Vu Dinh Mar 06 '18 at 10:00

0 Answers0