当发送无效电子邮件时发送电子邮件时,我会在控制台日志中收到“...不是有效的电子邮件地址”。
这没关系,我明白为什么会这样。
我想知道的是......这个NSLog语句来自哪里,我可以访问它吗?
在MFCVController或委托中的某个地方,框架正在检查电子邮件是否有效,然后相应地记录“...不是有效的电子邮件地址”。
我想访问此调用并检查相同的内容并创建alertView。
在评论之前,我已经知道了一些事情...... 我知道如何创建alertViews。 我知道并且已经阅读了用户创建的其他帖子,其中包含检查无效电子邮件地址字符串的代码。
感谢您的帮助!
其他信息:
这是一个有用的见解,它确实发生在这里:引用带有吊牌打印输出的NSLog。
if ([MFMailComposeViewController canSendMail])
{ NSLog(@"Log 1");
MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc]init];
mailer.mailComposeDelegate = self;
[mailer setSubject:@"Checklist Complete"];
NSLog(@"Log 2");
NSArray *toRecipients = [NSArray arrayWithObject:emailAddress];
NSLog(@"Log 3");
[mailer setToRecipients:toRecipients];
NSLog(@"Log 4");
NSString *emailBody = emailBodyContents;
NSLog(@"Log 5");
[mailer setMessageBody:emailBody isHTML:NO];
NSLog(@"Log 6");
//For iPad
//mailer.modalPresentationStyle = UIModalPresentationPageSheet;
[self presentViewController:mailer animated:YES completion:nil];
NSLog(@"Log 7");
}
控制台。
2014-01-15 21:11:30.581 AppTemplate[1018:70b] Log 1
2014-01-15 21:11:30.584 AppTemplate[1018:70b] Log 2
2014-01-15 21:11:30.585 AppTemplate[1018:70b] Log 3
2014-01-15 21:11:30.585 AppTemplate[1018:70b] (null) is not a valid email address.
2014-01-15 21:11:30.586 AppTemplate[1018:70b] Log 4
2014-01-15 21:11:30.586 AppTemplate[1018:70b] Log 5
2014-01-15 21:11:30.587 AppTemplate[1018:70b] Log 6
2014-01-15 21:11:30.588 AppTemplate[1018:70b] Log 7
这是我在Xcode中找到的文档
- (void)setToRecipients:(NSArray *)toRecipients __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0)
/*!
@method setCcRecipients:
@abstract This method sets the CC header for the email message to the specified email addresses.
@discussion This method will set the CC header for the email message. This should be called prior to display.
</p>Recipient addresses should be specified as per RFC5322.
</p>After the view has been presented to the user, this method will no longer change the value.
@param ccRecipients A NSArray of NSString instances specifying the email addresses of recipients.
* /
答案 0 :(得分:0)
您应该设置删除并检测是否发生了错误:
- (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error{
switch (result)
{
case MFMailComposeResultCancelled:
NSLog(@"Mail cancelled");
break;
case MFMailComposeResultSaved:
NSLog(@"Mail saved");
break;
case MFMailComposeResultSent:
NSLog(@"Mail sent");
break;
case MFMailComposeResultFailed:
NSLog(@"Mail sent failure: %@", [error localizedDescription]);
break;
default:
break;
}
// Close the Mail Interface
[self dismissViewControllerAnimated:YES completion:NULL];}