使用MFMailComposeViewController时出现问题 [英] Issue when using MFMailComposeViewController

查看:130
本文介绍了使用MFMailComposeViewController时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个棘手的问题。在我的一个应用程序中,有超过150,000次下载...我遇到了一个很少发生的问题,我似乎无法弄明白。

I have a tricky problem. In one of my app, with over 150.000 downloads... I have a problem which seldom occurs and which I can't seem to figure out.

问题是以下:
在用户可以通过电子邮件共享列表的视图中,我使用 MFMailComposeViewController 打开邮件窗口。但是,在少数情况下,应用程序似乎使用邮件编写器出现问题。用户按下共享按钮,邮件窗口向上滑动,等待约1-2秒,然后再次关闭。邮件窗口中没有内容,但我确实向其发送数据。
我自己无法在任何设备或模拟器中重新创建问题,但是有一位同事。
我在他的手机上使用XCode运行应用程序并在日志中获得以下内容:

The problem is the following: In a view where the user can share a list via email, I open the mail window using MFMailComposeViewController. However, in some few cases the app seems to get a problem using the mail composer. The user presses the share button, the mail windows slides up, waits about 1-2 sec and then closes again. No content in the mail window, although I do send data to it. I myself have not been able to re-create the problem on any device or in the simulator, however one colleague has. I ran the app using XCode on his phone and got the following in the logs:

2013-03-01 14:43:39.604 appname[318:907] <MFMailComposeRemoteViewController: 0x1ebfb100> timed out waiting for fence barrier from com.apple.MailCompositionService
2013-03-01 14:43:39.631 appname[318:907] viewServiceDidTerminateWithError: Error Domain=XPCObjectsErrorDomain Code=2 "The operation couldn’t be completed. (XPCObjectsErrorDomain error 2.)"

我搜索了错误等待来自com的围栏屏障的时间超时。 apple.MailCompositionService但无法找到任何帮助。

I googled the error "timed out waiting for fence barrier from com.apple.MailCompositionService" but can't really find any help.

有没有人有这方面的经验?我该如何解决?

Does anybody have any experience with this? How can I solve it?

我打开视图的代码:

-(void)displayComposerSheetWithBodyString:(NSString *)aBody
{
    if ([MFMailComposeViewController canSendMail])
    {
        MFMailComposeViewController *picker = [[MFMailComposeViewController alloc]init];
        picker.mailComposeDelegate = self;

        [picker setSubject:@"Lista"];

        NSString *emailBody = aBody;
        [picker setMessageBody:emailBody isHTML:NO];

        [self.navigationController presentModalViewController:picker animated:YES];
    }
    else
    {
        [[[UIAlertView alloc]initWithTitle:NSLocalizedString(@"Din enhet är inte redo att skicka e-post. Kontrollera dina inställningar", nil)
                                   message:nil
                                  delegate:self
                         cancelButtonTitle:NSLocalizedString(@"OK", nil)
                         otherButtonTitles:nil]
         show];
    }
}


推荐答案

不确定你是否解决了这个问题,但我最近在我的项目中遇到了它。

Not sure if you have fixed the problem, but I have met it recently in my project.

我做的一个解决方法是在早期阶段分配和启动MFMailComposeViewController ,并将其保存在一个静态变量中,只要需要它,获取静态MFMailComposeViewController实例并显示它。

A workaround I did was to 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.

它似乎对我有用,希望它会也适合你。

It seems working for me, hope it will work for you, too.

这篇关于使用MFMailComposeViewController时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆