Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

kennedy otis
kennedy otis
3,570 Points

How to open UITextView link in custom UIViewController

Hello How can one open a link from UITextView in another UIViewController instead of the default behaviour (opening via safari). What am trying to achieve is the same approach twitter app uses when one clicks on a link. Any help will be appreciated.

5 Answers

Patrick Donahue
Patrick Donahue
9,523 Points

Are you opening the link in a UIWebView?

Could just create your own "web browser" in app.

kennedy otis
kennedy otis
3,570 Points

Yes I would like to listen to that link click then push that to another view controller which has webview to display the content of that link.. Same like the twitter app. How can I listen to link click from uitextview ?

Patrick Donahue
Patrick Donahue
9,523 Points

This Stack Overflow answer seems to be basic enough. I am not sure where you are getting the link from. But like SO says you could just change the color of the text and make it a custom button instead - if it is always going to be a link.

kennedy otis
kennedy otis
3,570 Points

Am fetching remote data and some comes with link.

Patrick Donahue
Patrick Donahue
9,523 Points

Hmm... can you check what is coming back through and if statement and change things accordingly?

kennedy otis
kennedy otis
3,570 Points

Are you asking about checking remote data? Am actually reading blog content

Patrick Donahue
Patrick Donahue
9,523 Points

I was just talking it out. This is the opposite of what you want. But it should help.