I am creating a simple point annotation with UITapGestureRecognizer within the UITapGestureRecognizer delegate.
The first time I click on the card, the output appears with the offset, but after that the shutdown immediately disappears.
The second time, when I click the same output, an inscription appears and remains there, not knowing why it disappears for the first time.
@IBAction func handleMapTouch(recognizer: UITapGestureRecognizer){ let view = recognizer.view let touchPoint=recognizer.locationInView(view) var touchCord=CLLocationCoordinate2D() touchCord = mapView.convertPoint(touchPoint, toCoordinateFromView: mapView) mapView.removeAnnotations(mapView.annotations) pointAnnotation.coordinate=touchCord pointAnnotation.title="ABC" pointAnnotation.subtitle="DEF" mapView.addAnnotation(pointAnnotation) mapView.selectAnnotation(pointAnnotation, animated: true) }
source share