【问题标题】:The MFmailcomposer is sometime giving error?MFmailcomposer 有时会出错?
【发布时间】:2012-10-04 06:25:47
【问题描述】:

我正在使用 MFMailcomposer 从我在 iPhone 中的应用程序发送邮件。一切正常,但是当我将它移植到 iPhone 5 和 ios6 时

_serviceViewControllerReady:error: Error Domain=_UIViewServiceInterfaceErrorDomain Code=1 "The operation couldn’t be completed. (_UIViewServiceInterfaceErrorDomain error 1. 但如果我再次运行没有问题,它工作正常。

我正在像这样展示邮件编写器`

action
{
Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
    if (mailClass != nil)
    {
        // We must always check whether the current device is configured for sending emails
        if ([mailClass canSendMail])
        {
            [self displayComposerSheet];
        }
        else
        {
            [self launchMailAppOnDevice];
        }
    }
    else
    {
        [self launchMailAppOnDevice];
    }

}


void)displayComposerSheet 
{

    AppDelegate *appdelegate=[[UIApplication sharedApplication] delegate];
    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
    picker.mailComposeDelegate = self;  

    [picker setSubject:@"report"];



    // Set up recipients
    NSArray *toRecipients=[NSArray arrayWithObject:@""]; 
    NSArray *ccRecipients =[[NSArray alloc]init];//= [NSArray arrayWithObjects:@"", @"", nil]; 
    NSArray *bccRecipients=[[NSArray alloc]init];// = [NSArray arrayWithObject:@""];    
    [picker setToRecipients:toRecipients];
    [picker setCcRecipients:ccRecipients];  
    [picker setBccRecipients:bccRecipients];    
    [picker setMessageBody:@"Please send me  now." isHTML:YES];





    [appdelegate.navigationController presentModalViewController:picker animated:YES];
    [appdelegate.navigationController.navigationBar setHidden:NO];
    [picker release];
}

`

【问题讨论】:

  • 当打开控制器发送邮件后出现那个错误?
  • 显示一些展示 MFMailcomposer 视图的代码..
  • @neonsamuel 它在瞬间打开控制器,但没有做任何事情就关闭了
  • @bugfinder 请在设备中运行应用程序并检查一下
  • 它也发生在我身上......我猜这是iOS6的问题。我的(快速...)解决方案是打开 mail.app 而不是这个。

标签: iphone ios ipad


【解决方案1】:

我遇到了同样的问题,这似乎是一个与特定 UIAppearance 自定义相关的错误。当我删除我对 UISearchBar 背景图像的自定义时,它完全消失了。

【讨论】:

  • 对我来说,它是 UIBarButtonItem 上的 tintColor。
  • 完全随机且绝对是一个奇怪的问题,现在在将应用程序构建到未启用 Arm64 的 64 位设备上时始终会发生这种情况。我正在报告雷达。
  • 这已经让我发疯了大约 4 个小时。注释掉我所有的 UIAppearance 定制莫名其妙地解决了这个问题。显然这不是一个长期的解决方案,但感谢你让我没有发疯。我还将提交一个雷达以增加修复这个令人麻木的错误的压力
  • 同样的错误发生在我身上,Xcode 5.0.2 并在 iOS 7 上看到。对我来说打破它的 UIAppearance 是 [[UIBarButtonItem 外观] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -1000) forBarMetrics:UIBarMetricsDefault];
  • 我现在遇到了同样的错误,从我的 AppDelegate 中注释掉这一行使它消失了:[[UILabel appearance] setFont:...],所以它仍然存在。我设置了其他似乎不会引起问题的外观属性。另一个奇怪的事情是,我在许多不同的地方展示了 MFMailComposerViewController,而且似乎只有一个 VC 出现了这个错误。
【解决方案2】:

您应该使用:presentModalViewController 在 iOS 6 中已弃用。

[appdelegate.navigationController presentViewController:picker animated:YES completion:nil];

而不是

[appdelegate.navigationController presentModalViewController:picker animated:YES];

【讨论】:

  • 如何删除?dismismodalviewcontroller?我将部署目标用作 ios5,然后我认为这不是问题?
  • 我很确定这不是一个因素。使用 presentViewController 时出现相同的错误。 (但仅在模拟器上。)
【解决方案3】:

我也遇到了同样的问题,但最后解决了。

关闭xcode,重启系统,就可以了。

【讨论】:

    【解决方案4】:

    试试这个,

     [self presentModalViewController:picker animated:YES];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-11-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多