Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to parse and show hyperlinks (phone number/email addresses etc) in UILabel?

Tags:

iphone

Almost everywhere in the iPhone, you can type text and the OS will recognize portion of the text to be hyperlinks (phone numbers, email addresses for example). However I tested this in my own app with a UILabel and it doesn't work. How do I activate this?

Does the iphone sdk provide this functionality out of the box or do I have to do the parsing logic myself (which is a lot of work)?

like image 533
erotsppa Avatar asked Jul 05 '09 19:07

erotsppa


1 Answers

You could use UITextView as follows:

UITextView *myView = [[UITextView alloc] initWithFrame: frame];
myView.text = @"this is http://google.com link";
myView.editable = NO;
myView.dataDetectorTypes = UIDataDetectorTypeLink;
//cell is the TableView's cell    
[cell.contentView addSubview:myView];
[myView release];
like image 180
Danil Glinenko Avatar answered Nov 15 '22 04:11

Danil Glinenko