-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
NSString *eventResult = nil;
[self dismissModalViewControllerAnimated:YES];
switch (result) {
case MFMailComposeResultSent:
eventResult = @"Mail Sent Succesfully";
break;
case MFMailComposeResultSaved:
eventResult = @"Saved into draft";
break;
case MFMailComposeResultCancelled:
eventResult = @"Mail Canceled";
break;
case MFMailComposeResultFailed:
NSLog(@"Mail Fail:%@",[error localizedDescription]);
eventResult = @"Mail failed";
break;
}
//alert for show status of mail
UIAlertView *mailStatusAlert = [[UIAlertView alloc]initWithTitle:@"Email Alert" message:eventResult delegate:nil cancelButtonTitle:nil otherButtonTitles:@"Ok", nil];
[mailStatusAlert show];
[mailStatusAlert release]
我使用上面的代码来处理邮件状态,当 wifi 打开时,它工作正常,但如果 wifi 关闭,错误不会显示为失败。但我需要那张支票。还有其他方法可以处理该错误吗?我可以禁用横向的 mailcomposeviewcontroller 方向吗,因为我的应用程序仅支持纵向。
最佳答案
来自官方doc ,在概述部分,对此问题提供了解释:
This allows you to generate emails even in situations where the user does not have network access, such as in airplane mode. This interface does not provide a way for you to verify whether emails were actually sent.
因此,在生成电子邮件时无需担心互联网连接。
正如 spider1983 所提到的,值得使用 Apple 的 Reachability 类或 third-party 检查您的互联网连接。 (最后一个兼容ARC和GCD)
关于ios - wifi 关闭时邮件未发送且未显示错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14069378/