电子邮件沉着iOS 8 [英] Email composure iOS 8
问题描述
我正在尝试从Xcode 6在iOS 8中打开电子邮件,但收到错误。如果我从Xcode 5开始尝试,相同的代码工作正常。后来我从apple开发者门户网站下载了一个示例代码:
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:
https://developer.apple.com/library/content/samplecode/MessageComposer/Introduction/Intro.html
但结果是一样的。有什么东西,或某些设置,我缺少优化Xcode 6的代码
But the result is same. Is there something, or some setting, I'm missing to optimise the code for 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:@"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
email composure delegate disappearing automatically with result 0, i.e., MFMailComposeResultCancelled
错误代码:MessageComposer [10993:196902]
viewServiceDidTerminateWithError:错误
Domain = _UIViewServiceInterfaceErrorDomain Code = 3操作
无法完成。(_UIViewServiceInterfaceErrorDomain error 3.)
UserInfo = 0x7b93f7e0 {Message = Service Connection Interrupted}
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}
和
2014-09-17 22:04: 22.538 MessageComposer [10993:205761]
超时等待来自com.apple.MailCompositionService的
栅栏屏障
2014-09-17 22:04:22.538 MessageComposer[10993:205761] timed out waiting for fence barrier from com.apple.MailCompositionService
推荐答案
从外观上看,这只是一个模拟器问题。 (iOS 8模拟器)
globalMailer方法适用于设备。
By the looks of it, this is a simulator-only issue. (iOS 8 simulator) The globalMailer approach works ok on devices.
如果有人遇到此问题,只需在真实设备上进行测试。
If anyone encounters this problem, just test on a real device.
这篇关于电子邮件沉着iOS 8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!