9

我正在使用 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];
}

`

4

4 回答 4

6

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

于 2012-12-14T23:16:15.040 回答
5

您应该使用 : As presentModalViewControlleris deprecated in iOS 6。

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

代替

[appdelegate.navigationController presentModalViewController:picker animated:YES];
于 2012-10-04T06:46:02.167 回答
2

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

关闭xcode并重新启动系统,它会工作。

于 2013-01-21T14:01:13.530 回答
0

尝试这个,

 [self presentModalViewController:picker animated:YES];
于 2012-10-04T11:31:03.610 回答