MFmailcomposer有时会出错?

时间:2012-10-04 06:25:47

标签: iphone ios ipad

我正在使用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 个答案:

答案 0 :(得分:6)

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

答案 1 :(得分:5)

您应该使用:在iOS 6中不推荐使用presentModalViewController

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

而不是

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

答案 2 :(得分:2)

我也面临同样的问题,但终于解决了它。

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

答案 3 :(得分:0)

试试这个,

 [self presentModalViewController:picker animated:YES];