Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The MFmailcomposer is sometime giving error?

Tags:

ios

iphone

ipad

I am using MFMailcomposer for sending mail from my application in IPhone.It is all working fine,but when i port it to iPhone 5 and ios6 sometime

_serviceViewControllerReady:error: Error Domain=_UIViewServiceInterfaceErrorDomain Code=1 "The operation couldn’t be completed. (_UIViewServiceInterfaceErrorDomain error 1. but if i run again there is no problem it was working fine.

I am presenting the mail composer like this `

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];
}

`

like image 279
hacker Avatar asked Oct 04 '12 06:10

hacker


3 Answers

I had the same issue, and it seems to be a bug that is related to specific UIAppearance customizations. It goes away entirely when I remove my customization of UISearchBar background images.

like image 86
omz Avatar answered Nov 12 '22 17:11

omz


You should use : As presentModalViewController is deprecated in iOS 6.

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

instead of

[appdelegate.navigationController presentModalViewController:picker animated:YES];
like image 20
Maulik Avatar answered Nov 12 '22 18:11

Maulik


I also faced this same problem but at last solved it.

Close xcode and restart system, it will work.

like image 2
Ajeet Avatar answered Nov 12 '22 18:11

Ajeet