ios - wifi 关闭时邮件未发送且未显示错误

标签 ios wifi mfmailcomposeviewcontroller

-(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/

相关文章:

ios - 我们如何将一个 UIView 设置为另一个 UIView 的掩码

python - iOS 推送通知 (APNs) 通过 GAE,SSL 握手失败

javascript - 如何使用 Javascript 和 PHP 从浏览器连接到 WIFI?

javascript - 使用 NodeJS 检测用户是否正在访问我的网络(WIFI)

ios - Xcode7 : How to mail crash report in swift

ios - 当我在 VC B 中时,如何使用本应在 VC A 中使用的通知中的数据

IOS dealloc 永远不会被调用

Android:从 broadcastReceiver 更新 listView 中的进度条

iphone - 如何在应用程序 iphone 中添加 .vcf 文件作为附件

ios - 不允许在 View Controller 解除分配时尝试加载 View ,这可能会导致未定义的行为