aherlambang
aherlambang

Reputation: 14418

detecting URL and format it in UITextField

I would like to be able to format a URL in my UITextField nicely. So say the text of the UITextField is

textField.text = @"Hi this is a page for my website http://www.mywebsite.com";

I would like it to automatically underline this mark it as a hyperlink and when a user taps on the link it opens up the site. This is similar to any twitter client that you have out there (tweetdeck, tweetbot, etc). How do I do this the easy way?

Upvotes: 4

Views: 5097

Answers (2)

Sam Keene
Sam Keene

Reputation: 297

hey this is really simple, you can set the UITextFiled to detect Links, like so:

myTextView.dataDetectorTypes = UIDataDetectorTypeAll

check out my tutorial on this at my site for more info http://www.sdkboy.com

Upvotes: 1

jaminguy
jaminguy

Reputation: 25940

You can use a UITextView instead and set the dataDetectorTypes property to the types of links you want to be able to handle.

Upvotes: 5

Related Questions