【发布时间】:2012-09-19 09:39:38
【问题描述】:
我遇到了很长一段时间以来遇到的最奇怪的问题......而且我已经没有想法了。
所以我有一个 MFMailComposeViewController,它通过点击 UIButton 启动,它启动邮件编写器视图就好了。您会看到我分配的主题,但在 to: 或 body 字段填充之前,窗口会闪烁并消失。它抛出这个错误:
viewServiceDidTerminateWithError: Error Domain=XPCObjectsErrorDomain Code=2 “操作无法完成。(XPCObjectsErrorDomain 错误 2.)”
现在是疯狂的部分。如果我切换到另一个也使用 MFMailComposeViewController 的应用程序并启动该应用程序,然后切换回我的应用程序并再次启动邮件编写器,它就可以正常工作。我无法解释。
这似乎只在运行 iOS 6 且不是 iPhone 5 的手机上存在问题。
我四处搜寻,似乎找不到遇到同样问题的其他人。有人有什么建议吗?
我已经链接了 MessageUI.framework,我还发现这在模拟器或设备上不起作用,但是当我还链接 Security.framework 时,它开始在模拟器中工作,但它仍然没有不能在设备上工作。
我的启动 MFMailComposeViewController 的代码如下:
在 .h 文件中
#import <MessageUI/MessageUI.h>
#import <MessageUI/MFMailComposeViewController.h>
在 .m 文件中
-(void)displayComposerSheet {
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:@"Support Request"];
// Set up recipients
NSArray *toRecipients = [NSArray arrayWithObject:@"support@domain.com"];
[picker setToRecipients:toRecipients];
// Fill out the email body text
NSString *emailBody = @"\n\nEmail from iOS";
[picker setMessageBody:emailBody isHTML:NO];
[self presentModalViewController:picker animated:YES];
}
// Dismisses the email composition interface when users tap Cancel or Send. Proceeds to update the message field with the result of the operation.
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
[self dismissModalViewControllerAnimated:YES];
}
更新:我认为我已将其范围缩小到我已传递给 UINavigationBar 外观委托的设置。我有它使用自定义字体,如果我将其关闭,它似乎可以工作......但为什么它会在 iPhone5 上工作......
【问题讨论】:
-
从 UIActivityViewController 调用时遇到同样的问题...你找到解决办法了吗?
-
不,但我确实确定还有其他因素影响它,因为我制作了一个示例项目,它只做了这个,没有别的,它工作得很好。但我从来没有弄清楚问题的根源。目前,我只是针对这种情况将字体更改为系统字体,其余的则保留。
-
@gplocke 回答你自己的问题
-
我已将其归档为 rdar://13422715 (openradar.me/13422715)
标签: objective-c ios ios6