Make phone number clickable in uitextview on map in swift

223 Views Asked by At

I want to make phone numbers in a UITextView on a MapView tappable using datadetector but it is not working.

The textView in question is a subview of a generic UIView which is a subview of an MKAnnotationView on a Map so perhaps something in the hierarchy of subviews is causing the problem.

Here is the code to configure the textView:

textView.font = UIFont.systemFont(ofSize: 14)
textView.isUserInteractionEnabled = true
textView.isSelectable = true
textView.isEditable = false
textView.dataDetectorTypes = UIDataDetectorTypes.all
//mycustomview is a plain rectangular uiview
myCustomView.addSubview(textView)
//annotationview is an MKAnnotationView
 annotationView.addSubview(myCustomView)

Thanks in advance for any suggestions

0

There are 0 best solutions below