9

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

`

hacker
  • 8,919
  • 12
  • 62
  • 108
  • When the opening the controller mail send after that error occurred? – Nimit Parekh Oct 04 '12 at 06:28
  • show some code of presenting the MFMailcomposer view.. – Maulik Oct 04 '12 at 06:29
  • 1
    @neonsamuel it was opening the controller in a flash and without doing anything it dismisses – hacker Oct 04 '12 at 06:31
  • @bugfinder please run application into the device and check it out – Nimit Parekh Oct 04 '12 at 06:32
  • It happend to me too... I guess it's a problem with iOS6. My (fast...) solution was opening the mail.app instead of this. – Bernat Oct 04 '12 at 06:39
  • I tried hard to find a solution, but I had to submit the app that day, so my solution was something like this: http://stackoverflow.com/questions/8821934/how-can-i-launch-apple-mail-app-from-within-my-own-app – Bernat Oct 04 '12 at 06:54
  • @Bernat i am using iOS 5 as deployment target .so the bellow ans may not be the issue is it? – hacker Oct 04 '12 at 08:36
  • I got the same errors, when presenting an MFMailComposeViewController. The error only appears for me when using the simulator, not on device, so for now I'm chalking it up to a simulator bug. And for the record, I'm using the newer "presentModalViewController" syntax instead of the older "presentModalViewController" method, so I don't think that's a factor (as suggested in other answers). – ceperry Jan 08 '13 at 15:47

4 Answers4

6

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.

omz
  • 53,243
  • 5
  • 129
  • 141
  • For me it was the tintColor on a UIBarButtonItem. – Saltymule Jan 10 '13 at 14:06
  • completely random and definitely a weird issue, which is now occurring consistently when building the app onto a 64 bit device without Arm64 enabled. I am reporting a Radar. – Dima Sep 30 '13 at 23:39
  • this has been driving me insane for about 4 hours now. Commenting off all my `UIAppearance` customization inexplicably fixed the issue. Obviously that isn't a long term solution, but thanks for making me not crazy. I'll also file a radar to up the pressure to fix this mind numbing bug – SRandazzo Oct 14 '13 at 16:05
  • 1
    Same bug happening for me, Xcode 5.0.2 and seen on iOS 7. The UIAppearance breaking it for me was [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -1000) forBarMetrics:UIBarMetricsDefault]; – ben_the_builder Dec 02 '13 at 14:49
  • I just ran into the same bug now, commenting out this line from my AppDelegate made it go away: [[UILabel appearance] setFont:...], so it is still there. I have other appearance properties set that don't seem to be causing an issue. Another weird thing is that I present MFMailComposerViewController in many different places and only one VC seems to exhibit this bug. – Bek Sep 03 '14 at 00:51
5

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];
Maulik
  • 19,348
  • 14
  • 82
  • 137
  • how to remove that?dismismodalviewcontroller? I was using deployment target as ios5 then i think this is not the problem? – hacker Oct 04 '12 at 07:21
  • I'm pretty sure this isn't a factor. I get the same errors when use presentViewController. (But only on the simulator.) – ceperry Jan 08 '13 at 15:52
2

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

Close xcode and restart system, it will work.

Eonasdan
  • 7,563
  • 8
  • 55
  • 82
Ajeet
  • 157
  • 7
0

try this,

 [self presentModalViewController:picker animated:YES];
Venk
  • 5,949
  • 9
  • 41
  • 52