首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Email composure iOS 8

Email composure iOS 8
EN

Stack Overflow用户
提问于 2014-09-18 00:20:53
回答 1查看 19.5K关注 0票数 51

我正在尝试从Xcode6在iOS 8中打开email composure,但是收到一个错误。如果我在Xcode 5上尝试,同样的代码也可以正常工作。后来,我从苹果开发者门户网站下载了一个示例代码:

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

但是结果是一样的。在优化Xcode6的代码时,我是否遗漏了一些东西或设置

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

代码语言:javascript
复制
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];

电子邮件委派

代码语言:javascript
复制
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

错误代码: MessageComposer10993:196902 viewServiceDidTerminateWithError: error Domain=_UIViewServiceInterfaceErrorDomain Code=3“无法完成操作。(_UIViewServiceInterfaceErrorDomain错误3。)”UserInfo=0x7b93f7e0 {Message=Service连接中断}

2014-09-17 22:04:22.538 MessageComposer10993:205761等待来自com.apple.MailCompositionService

的栅栏超时

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-09-24 01:58:46

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

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

票数 102
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25895634

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档