NEW: Learn to build the incredible iOS 15 Weather app today! >>

Make URLS clickable

Forums > iOS

In my app the user can enter notes/annotations in Textfields. I store the data in json files. All well and dandy. What I'd like to add is to make urls in the notes clickable when viewing them (not when entering them) and open them in app in a SafariViewController...

Doable? Any pointers?

   

You need to use UITextView, this has automatic links detection and it will make them tappable.

Next step is to use this delegate method, return false and manually open the SFSafariViewController :-)

1      

I do use TextViews, my bad! I will try that out! Thanks Filip!

   

On second thought, for viewing (in table cells ie) they are labels I think. I use TextViews for entering the data. Ok, might have to rethink this ...

   

There are some cumbersome ways to make this work for labels I think but TextView will be easier solution.

   

I'll have to rewrite some stuff then, gonna give it a go ...

   

In my app the user can enter notes/annotations in Textfields. I store the data in json files. All well and dandy. What I'd like to add is to make urls in the notes clickable when viewing them (not when entering them) and open them in app in a SafariViewController...

I am also looking for the same solution.

   

Hacking with Swift is sponsored by Sentry

SPONSORED With Sentry’s error and performance monitoring for iOS, you see mobile vitals that actually matter, can solve any latency issues quickly, and learn how each release is performing over time.

Learn More

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.