24

情况是要呈现 MFMailComposeViewController。我看到它已经完成了一半,但后来被解雇了。

这是错误:

_serviceViewControllerReady:error: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 “操作无法完成。(_UIViewServiceInterfaceErrorDomain error 3.)”

这是我展示 MFMailComposeViewController 的源代码:

-(void) MailExecute {
    if ([MFMailComposeViewController canSendMail]) 
    {
        MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];   
        mailViewController.mailComposeDelegate = self;
        [mailViewController setSubject:NSLocalizedString(@"Check this new look", @"")];
        [mailViewController setMessageBody: @"my new look" isHTML:YES];

        [self presentModalViewController:mailViewController animated:YES];

        [mailViewController release];
    }
    else 
    {
        UIAlertView *alertInternal = [[UIAlertView alloc]
                                      initWithTitle: NSLocalizedString(@"Notification", @"")
                                      message: NSLocalizedString(@"You have not configured your e-mail client.", @"")
                                      delegate: nil
                                      cancelButtonTitle:NSLocalizedString(@"OK", @"")
                                      otherButtonTitles:nil];
        [alertInternal show];
        [alertInternal release];
    }
}

奇怪的是,有时会发生,有时不会。请帮我解决这个问题!我花了将近 1 个工作日来解决这个问题,但没有成功。

4

9 回答 9

3

This problem can occur when displaying a remote view controller -- a view controller run in another process -- as indicated by the UIViewService reference in the error message.

I've had this problem when displaying an SKStoreProductViewController, which is also a remote view controller. I'm not sure what the root cause is; the only thing that seemed to trigger it for me was presenting the view controller repeatedly.

For the SKStoreProductViewController I was able to check for this error in the completion block of the loadProductWithParameters:completionBlock: method. Does the MFMailComposeViewControllerDelegate give you a callback with an error about this? It may be that all you can do is listen for this error and show an error message to the user.

We should both probably file an apple radar about this.

于 2013-06-23T05:14:54.527 回答
2

您的代码看起来是正确的,并且如所述错误消息强烈表明这与UIView正确(不是MFMail特别)有关。几乎可以肯定,问题出在代码中的某个地方,并且可能难以排除故障。

一些要寻找的东西:

  1. 其他动画或视图控制器转换/关闭同时或不正确发生(可能像这样
  2. 释放/保留问题,当然

如果这些似乎都不是解决方法,请尝试注释掉调用此方法的视图控制器中发生的所有其他事情,然后看看它是否有效。

如果您仍然无法正常工作,请提供最简单的失败代码版本,以便我们进一步排除故障。:)

于 2012-12-25T09:00:13.880 回答
0

您的viewDidDisappear:viewWillDisappear方法中是否有任何会关闭视图控制器的内容?

如果没有,您能否为呈现 MFMailComposeViewController 的 ViewController 发布更多代码?

于 2012-12-21T13:11:49.040 回答
0

我知道这是迟到的答复,但可能会有所帮助。

刚刚面临同样的问题,通过resetting the simulator为我解决同样的问题。让我知道这是否有帮助。

于 2013-06-23T04:58:50.063 回答
0

对我来说,问题是调用附件函数时参数不正确。如果您在使用电子邮件附件时遇到此问题,我建议您按照此线程中的解决方案进行操作,如下所示:

NSString *path = [self getDatabaseFilePath];
NSData *myData = [NSData dataWithContentsOfFile:path];
[picker addAttachmentData:myData mimeType:@"application/x-sqlite3" fileName:[path lastPathComponent]];
于 2014-07-31T07:20:13.520 回答
0

MFMailComposeViewController *mailComposer = [[MFMailComposeViewController alloc]init];

if ([MFMailComposeViewController canSendMail])
{
    mailComposer.mailComposeDelegate = self;
    [mailComposer setToRecipients:[NSArray arrayWithObject:@"support@kapsie.com"] ];
    [mailComposer setSubject:@"Kapsie App Contact Support"];
    [mailComposer setMessageBody:@"Type Your Feedback message here" isHTML:NO];
    [self presentViewController:mailComposer animated:YES completion:nil];
}

使用上面的代码并在设备上检查它。

于 2014-11-19T07:12:03.313 回答
0

在我将 MFMailComposeViewController 存储在我的类的强属性中而不是局部变量中之后,我无法再重现自我关闭行为。

于 2014-03-14T18:41:20.747 回答
-1

在 iOS 6 中不推荐使用 modelViewController ,请使用

[self presentViewController:mailView animated:YES completion:nil];
于 2013-05-28T12:38:30.637 回答
-1

我面临同样的问题,解决方案是:

我删除了与整体应用程序外观相关的代码,例如

[[UILabel appearance]setText:@""] 

并替换为代码

[[UILabel appearanceWhenContainedIn:[self class], nil] setText:@""];

现在它工作正常,所以要小心整体应用程序外观的变化:它可能是导航栏的外观,等等

于 2014-08-01T10:07:02.070 回答