Sunday, October 28, 2012

How to make web address, mail id and phone number as a hyper link

Get contacts of all your emergency needs on single tap. Download Quick-Finder for iPhone

Problem Statement- want to make phone number and mail id as a hyper link so that user can make call and can mail directly on clicking the number


Solution:

1) For this you have to take textview as label does not support it
2) Take a text view.
3) Set text of text view by method

[self.testTextView set Text: @"http://www.google.com                test@test.com        1234567890"];


4) Now you have to make text view able to detect web address and mail id for that use following code

[self.testTextView setDataDetectorTypes:UIDataDetectorTypeAddress];
[self.testTextView setDataDetectorTypes:UIDataDetectorTypeLink];
[self.testTextView setDataDetectorTypes:UIDataDetectorTypePhoneNumber];

You can use 

[self.testTextView setDataDetectorTypes:UIDataDetectorTypeAll];

Instead of the above three line of code.

Now your code is prepare to run.

When you run the code you will get the screen like:







long press on the phone number or mail id , you will get the respective action.



1 comment:

  1. think your blog is pretty good which have some useful information. Thanks for sharing us!
    -----------------------------------------------------------------------------
    Php Development Services India, &&
    Hire Titanium Developer

    ReplyDelete