大佬教程收集整理的这篇文章主要介绍了ios – 如何在UITextView中单击电子邮件链接时打开iPhone的邮件应用程序?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
textview.editable = NO; textview.dataDetectorTypes = UIDataDetectorTypeAll;
您还应该能够在Interface Builder中设置detectorTypes.
单击UITextView中的电子邮件地址应该会自动打开Mail应用程序.
另外,如果您想从应用程序本身发送电子邮件,可以使用MFMailComposeViewController.
请注意,要@L_819_1@mFMailComposeViewController,需要在设备上安装Mail应用程序,并将一个帐户链接到该应用程序,否则您的应用程序将崩溃.
所以你可以用[MFMailComposeViewController canSendMail]来检查这个:
// check that a mail account is available if ([MFMailComposeViewController canSendMail]) { MFMailComposeViewController * emailController = [[MFMailComposeViewController alloc] init]; emailController.mailComposeDelegate = self; [emailController setSubject:subject]; [emailController setmessageBody:mailBody isHTML:YES]; [emailController setToRecipients:recipients]; [self presentViewController:emailController animated:YES completion:nil]; [emailController release]; } // Show error if no mail account is active else { UIAlertView * alertView = [[UIAlertView alloc] initWithtitle:@"Warning" message:@"you must have a mail account in order to send an email" delegate:nil cancelButtontitle:NSLocalizedString(@"OK",@"OK") otherButtontitles:nil]; [alertView show]; [alertView release]; }
以上是大佬教程为你收集整理的ios – 如何在UITextView中单击电子邮件链接时打开iPhone的邮件应用程序?全部内容,希望文章能够帮你解决ios – 如何在UITextView中单击电子邮件链接时打开iPhone的邮件应用程序?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。