How can I dynamically detect links/phone numbers/addresses etc in a SwiftUI Text

1.4k views Asked by At

I am using SwiftUI and would like to have something similar to .dataDetectorTypes in a UITextView to dynamically display content and allow links or phone numbers or addresses to be clickable in a SwiftUI Text or TextEditor.

As this will be for a chat app the content is dynamic and so just using .onTap won't work. Ideally I would like to use something like textView.dataDetectorTypes = .all in either a Text or TextEditor in SwiftUI but it seems that is not available.

Currently I'm using a UITextView Representable but having all sorts of issues there with dynamic height adjustment and scroll performance so hoping to find a SwiftUI way of doing this without UIViewRepresentable.

1

There are 1 answers

1
Matthaus Woolard On

This is not possible (as of the current version of swiftUI) you will need to continue to use UITextView for having a dynamic height have you looked at this post it might help with your height issues (maybe)...