mac*_*101 13 ios mfmailcomposeviewcontroller
我遇到了问题 MFMailComposeViewController
我收到了这个错误
viewServiceDidTerminateWithError: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "The operation couldn’t be completed. (_UIViewServiceInterfaceErrorDomain error 3.)" UserInfo=... {Message=Service Connection Interrupted}
Run Code Online (Sandbox Code Playgroud)
用这个代码
- (IBAction) mailbutton:(id)sender
{
if([MFMailComposeViewController canSendMail])
{
[MSAPP.globalMailComposer setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[self presentViewController:MSAPP.globalMailComposer animated:YES completion:nil];
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
message:@"Unable to mail. No email on this device?"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[MSAPP cycleTheGlobalMailComposer];
}
}
Run Code Online (Sandbox Code Playgroud)
这是 iOS 8 模拟器的一个已知问题。请参阅这篇文章了解可能的解决方法。
您必须在早期阶段分配和启动 MFMailComposeViewController,并将其保存在一个静态变量中,无论何时需要,获取静态 MFMailComposeViewController 实例并呈现它。
并且您几乎肯定必须在每次使用后“循环”全局 MFMailComposeViewController 。“重复使用”同一个东西并不可靠。有一个全局例程,用于释放然后重新初始化单例 MFMailComposeViewController。每次完成后调用它
这篇文章归功于“Joe Blow” 。从您的代码来看,您已经声明了全局邮件编辑器。尝试按照帖子的建议“回收”它,看看是否能解决您的问题。我遇到了同样的问题,不幸的是这个解决方案不能解决我的问题。我可以确认此解决方案适用于 iOS 7.1 模拟器,但不适用于 iOS 8,尽管有人建议它适用于物理 iOS 8 设备。