UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

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?

3      

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 :-)

4      

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

3      

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 ...

3      

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

3      

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

3      

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.

3      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

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

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

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.