我正在使用dataDetectorTypes属性与UITextView.code工作正常。当点击电子邮件地址时设置默认主题
当我点击链接的电子邮件作曲家出现带有预填充:[电子邮件地址],但我想设置默认主题:[主题字符串]也。
我该怎么做?
我正在使用dataDetectorTypes属性与UITextView.code工作正常。当点击电子邮件地址时设置默认主题
当我点击链接的电子邮件作曲家出现带有预填充:[电子邮件地址],但我想设置默认主题:[主题字符串]也。
我该怎么做?
MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];
mailController.mailComposeDelegate = self;
if([MFMailComposeViewController canSendMail]){
[mailController setSubject:@"Subject"];
[mailController setMessageBody:@"Email body here" isHTML:NO];
[mailController setMessageBody:[self getInFo] isHTML:YES];
[mailController setToRecipients:[NSArray arrayWithObject:@"[email protected]"]];
[mailController setTitle:@"Title"];
[self presentModalViewController:mailController animated:YES];
}else{
[mailController release];
}
这不是我要找的。当我尝试通过单击uitextview中的电子邮件发送邮件并将dataDetectorTypes属性设置为UIDataDetectorTypeAll时,我想添加主题。 – 2012-04-11 11:33:13
1)拳头将<UITextViewDelegate, MFMailComposeViewControllerDelegate>
添加到包含textview的类中。
您必须添加两个进口该类:
#import <MessageUI/MessageUI.h>
#import <MessageUI/MFMailComposeViewController.h>
2)添加一个变量:MFMailComposeViewController
(在这个例子中mailVC,你也可以将其添加为您的.h类属性)
3)实施下一个方法:
- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange
这允许截取特定的url交互。您可以取消特定的相互作用,并添加自己的行动,例如:
-(BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange{
//EXAMPLE CODE
if ([[URL scheme] isEqualToString:@"mailto"]) {
mailVC = [[MFMailComposeViewController alloc] init];
[mailVC setToRecipients:@[@"[email protected]"]];
[mailVC setSubject:@"A subject"];
mailVC.mailComposeDelegate = self;
[self presentViewController:mailVC animated:YES completion:^{
// [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}];
return NO;
}
return YES;
}
3)要关闭MFMailComposeViewController变量:
-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error{
[mailVC dismissViewControllerAnimated:YES completion:nil];
}
这对我的作品!
你是如何解决这个问题的? – 2014-01-30 11:50:06