ios – _UIViewServiceInterfaceErrorDomain

前端之家收集整理的这篇文章主要介绍了ios – _UIViewServiceInterfaceErrorDomain前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个MFMailComposeViewController的问题

我收到这个错误

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

用这段代码

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

解决方法

这是iOS 8模拟器的已知问题.请参阅 this post可能的解决方法.

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.

AND you will almost certainly have to “cycle” the global
MFMailComposeViewController after each use. It is not reliable to
“re-use” the same one. Have a global routine which release and then
re-initializes the singleton MFMailComposeViewController. Call it each
time after you are finished with it

信用到“Joe Blow”的职位.根据您的代码,您已经宣布了全球邮件作曲家.尝试“回收”它的帖子建议看看是否解决了你的问题.我有同样的问题,不幸的是,这个解决方案并不能解决我的问题.我可以确认此解决方案适用于iOS 7.1模拟器,但不支持iOS 8,尽管已经建议它可以在物理iOS 8设备上工作.

猜你在找的iOS相关文章