I am new in iPhone devlopment. I have an UITextView in a xib. There I displaying an email address link. I want to open iPhone’s mail application while clicking on that email link. How can I achieve that?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As pointed out in this answer, you can set the
dataDetectorTypesproperty of theUITextView:You should also be able to set the detectorTypes in Interface Builder.
From Apple documentation:
Clicking on the email address in your UITextView should then automatically open the Mail application.
On a side note, if you want to send the email from within your app itself, you can use the MFMailComposeViewController.
Note that for the MFMailComposeViewController to be shown, Mail app needs to be installed on the device, and have an account linked to it, otherwise your app will crash.
So you can check this with
[MFMailComposeViewController canSendMail]:MFMailComposeViewController Class Reference