WWDC22 SALE: Save 50% on all my Swift books and bundles! >>

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?

1      

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

2      

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

1      

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

1      

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

1      

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

1      

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.

1      

Hacking with Swift is sponsored by RevenueCat

SPONSORED You know StoreKit, but you don’t want to do StoreKit. RevenueCat makes it easy to deploy, manage, and analyze in-app subscriptions on iOS and Android so you can focus on building your app.

Explore the docs

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.