简体   繁体   English

_UIViewServiceInterfaceErrorDomain

[英]_UIViewServiceInterfaceErrorDomain

I'm having a problem with MFMailComposeViewController 我遇到了MFMailComposeViewController的问题

I'm getting this error 我收到了这个错误

viewServiceDidTerminateWithError: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "The operation couldn’t be completed. (_UIViewServiceInterfaceErrorDomain error 3.)" UserInfo=... {Message=Service Connection Interrupted}

with this code 用这个代码

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

This is a known issue with the iOS 8 simulator. 这是iOS 8模拟器的已知问题。 Please see this post for a possible workaround. 请参阅此帖子以获取可能的解决方法。

You MUST allocate and initiate MFMailComposeViewController in an earlier stage, and hold it in one static variable, whenever it's needed, get the static MFMailComposeViewController instance and present it. 您必须在早期阶段分配和启动MFMailComposeViewController,并在需要时将其保存在一个静态变量中,获取静态MFMailComposeViewController实例并显示它。

AND you will almost certainly have to "cycle" the global MFMailComposeViewController after each use. 并且你几乎肯定必须在每次使用后“循环”全局MFMailComposeViewController。 It is not reliable to "re-use" the same one. “重复使用”同一个是不可靠的。 Have a global routine which release and then re-initializes the singleton MFMailComposeViewController. 有一个全局例程,它释放然后重新初始化单例MFMailComposeViewController。 Call it each time after you are finished with it 完成后每次调用它

Credit goes to "Joe Blow" for the post. 这篇文章归功于“Joe Blow” Judging by your code, you have already declared global mail composer. 根据您的代码判断,您已经声明了全局邮件编写器。 Try "recycling" it as the post suggests to see if that solves your problem. 尝试“回收”它,如帖子建议,看看是否能解决您的问题。 I am having the same issue and unfortunately this solution doesn't fix mine. 我有同样的问题,不幸的是这个解决方案并没有解决我的问题。 I can confirm this solution works on the iOS 7.1 simulator but not iOS 8, although it has been suggested it will work on a physical iOS 8 device. 我可以确认这个解决方案适用于iOS 7.1模拟器但不适用于iOS 8,尽管有人建议它可以在物理iOS 8设备上运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM