How to make UITextView detect links for website, mail and phone number

AJ. picture AJ. · Jun 15, 2009 · Viewed 63.3k times · Source

I have a UITextView object. The text in UIView has a phone number, mail link, a website link. I want to show them as links with following functionality.

When someone taps on URL - Safari should open the the website. When someone taps on email link - Mail should open up with my address in to field When someone taps on phone number - Phone application should call the number

Has anyone done this before or knows how to handle it?

Thanks, AJ

Answer

aRrAY picture aRrAY · Aug 9, 2009

If you are using OS3.0

you can do it like the following

textview.editable = NO;
textview.dataDetectorTypes = UIDataDetectorTypeAll;