【问题标题】:Email composure iOS 8电子邮件镇静 iOS 8
【发布时间】:2014-09-17 16:20:52
【问题描述】:

我正在尝试从 Xcode 6 在 iOS 8 中打开电子邮件,但出现错误。如果我从 Xcode 5 尝试,相同的代码可以正常工作。后来我从苹果开发者门户下载了一个示例代码:

https://developer.apple.com/library/content/samplecode/MessageComposer/Introduction/Intro.html

但结果是一样的。有什么东西,或者一些设置,我缺少优化 Xcode 6 的代码

代码如下: 在我的按钮操作中

MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];

picker.mailComposeDelegate = self;

[picker setSubject:@"Hello from California!"];

// Set up recipients
NSArray *toRecipients = [NSArray arrayWithObject:@"first@example.com"]; 
NSArray *ccRecipients = [NSArray arrayWithObjects:@"second@example.com", @"third@example.com", nil]; 
NSArray *bccRecipients = [NSArray arrayWithObject:@"fourth@example.com"]; 

[picker setToRecipients:toRecipients];
[picker setCcRecipients:ccRecipients];  
[picker setBccRecipients:bccRecipients];

// Attach an image to the email
NSString *path = [[NSBundle mainBundle] pathForResource:@"rainy" ofType:@"jpg"];
NSData *myData = [NSData dataWithContentsOfFile:path];
[picker addAttachmentData:myData mimeType:@"image/jpeg" fileName:@"rainy"];

// Fill out the email body text
NSString *emailBody = @"It is raining in sunny California!";
[picker setMessageBody:emailBody isHTML:NO];

[self presentViewController:picker animated:YES completion:NULL];

电子邮件代表

self.feedbackMsg.hidden = NO;
// Notifies users about errors associated with the interface
switch (result)
{
    case MFMailComposeResultCancelled:
        self.feedbackMsg.text = @"Result: Mail sending canceled";
        break;
    case MFMailComposeResultSaved:
        self.feedbackMsg.text = @"Result: Mail saved";
        break;
    case MFMailComposeResultSent:
        self.feedbackMsg.text = @"Result: Mail sent";
        break;
    case MFMailComposeResultFailed:
        self.feedbackMsg.text = @"Result: Mail sending failed";
        break;
    default:
        self.feedbackMsg.text = @"Result: Mail not sent";
        break;
}

[self dismissViewControllerAnimated:YES completion:NULL];

结果:

电子邮件镇静委托自动消失,结果为 0, 即,MFMailComposeResultCancelled

带有错误代码:MessageComposer[10993:196902] viewServiceDidTerminateWithError: 错误 Domain=_UIViewServiceInterfaceErrorDomain Code=3 "操作 无法完成。 (_UIViewServiceInterfaceErrorDomain 错误 3.)" UserInfo=0x7b93f7e0 {Message=服务连接中断}

2014-09-17 22:04:22.538 MessageComposer[10993:205761] 超时等待 来自 com.apple.MailCompositionService 的栅栏屏障

【问题讨论】:

  • 错误是什么?在您的问题中显示相关代码。
  • 再次,错误是什么?哪条线?
  • @hoiberg42 你是对的,这是我在电子邮件镇静控制器自行解散后得到的错误代码。
  • 我刚刚在 iOS 8 设备上进行了测试,似乎 globalMailer 可以工作。所以一定是模拟器问题...

标签: ios objective-c xcode ios8 xcode6gm


【解决方案1】:

从外观上看,这是一个仅限模拟器的问题。 (iOS 8 模拟器) globalMailer 方法在设备上运行良好。

如果有人遇到这个问题,请在真机上测试。

【讨论】:

  • 我也只在模拟器中遇到过这个问题。通过试飞在设备上进行了测试,一切正常。
  • 如果您在运行 iOS7.1 的模拟器上进行测试,您的代码也可以正常工作
  • 我在 iOs 模拟器上也有同样的问题,但在真机上工作正常 :)
  • 怎么还能这样?我在模拟器上遇到 9.1 和 9.0 的相同错误。
猜你喜欢
  • 1970-01-01
  • 2021-02-15
  • 1970-01-01
  • 1970-01-01
  • 2011-09-17
  • 2016-07-13
  • 2014-07-23
  • 1970-01-01
相关资源
最近更新 更多