xcode 电子邮件沉着 iOS 8

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25895634/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 05:35:23  来源:igfitidea点击:

Email composure iOS 8

iosobjective-cxcodeios8xcode6gm

提问by Chahal

I'm trying to open email composure in iOS 8 from Xcode 6, but getting an error. The same code is working fine if I'm trying from Xcode 5. Later I downloaded a sample code from apple developer portal:

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

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

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

But the result is same. Is there something, or some setting, I'm missing to optimise the code for Xcode 6

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

Here is the code: in my button action

这是代码:在我的按钮操作中

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

picker.mailComposeDelegate = self;

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

// Set up recipients
NSArray *toRecipients = [NSArray arrayWithObject:@"[email protected]"]; 
NSArray *ccRecipients = [NSArray arrayWithObjects:@"[email protected]", @"[email protected]", nil]; 
NSArray *bccRecipients = [NSArray arrayWithObject:@"[email protected]"]; 

[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];

email delegate

电子邮件委托

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];

result:

结果:

email composure delegate disappearing automatically with result 0, i.e., MFMailComposeResultCancelled

with error codes : MessageComposer[10993:196902] viewServiceDidTerminateWithError: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "The operation couldn't be completed. (_UIViewServiceInterfaceErrorDomain error 3.)" UserInfo=0x7b93f7e0 {Message=Service Connection Interrupted}

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

错误代码:MessageComposer[10993:196902] viewServiceDidTerminateWithError: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 “操作无法完成。(_UIViewServiceInterfaceErrorDomain 错误 3.)” UserInfo=0x7b93f7e0 {Message=Service Connection Interrupted}

and

2014-09-17 22:04:22.538 MessageComposer[10993:205761] timed out waiting for fence barrier from com.apple.MailCompositionService

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

回答by Vrasidas

By the looks of it, this is a simulator-only issue. (iOS 8 simulator) The globalMailer approach works ok on devices.

从表面上看,这是一个仅限模拟器的问题。(iOS 8 模拟器) globalMailer 方法在设备上运行正常。

If anyone encounters this problem, just test on a real device.

如果有人遇到此问题,只需在真实设备上测试即可。