_UIViewServiceInterfaceErrorDomain
Asked Answered
H

1

14

I'm having a problem with MFMailComposeViewController

I'm getting this error

viewServiceDidTerminateWithError: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "The operation couldn’t be completed. (_UIViewServiceInterfaceErrorDomain error 3.)" UserInfo=... {Message=Service Connection Interrupted}

with this code

- (IBAction) mailbutton:(id)sender 
{

    if([MFMailComposeViewController canSendMail]) 
    {

        [MSAPP.globalMailComposer setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
        [self presentViewController:MSAPP.globalMailComposer animated:YES completion:nil];

    } 
    else 
    {

        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
                                                    message:@"Unable to mail. No email on this device?"
                                                   delegate:self
                                          cancelButtonTitle:@"OK"
                                          otherButtonTitles:nil];
        [alert show];
        [MSAPP cycleTheGlobalMailComposer];
    }
}
Howsoever answered 21/9, 2014 at 16:0 Comment(0)
I
3

This is a known issue with the iOS 8 simulator. Please see this post for a possible workaround.

You MUST allocate and initiate MFMailComposeViewController in an earlier stage, and hold it in one static variable, whenever it's needed, get the static MFMailComposeViewController instance and present it.

AND you will almost certainly have to "cycle" the global MFMailComposeViewController after each use. It is not reliable to "re-use" the same one. Have a global routine which release and then re-initializes the singleton MFMailComposeViewController. Call it each time after you are finished with it

Credit goes to "Joe Blow" for the post. Judging by your code, you have already declared global mail composer. Try "recycling" it as the post suggests to see if that solves your problem. I am having the same issue and unfortunately this solution doesn't fix mine. I can confirm this solution works on the iOS 7.1 simulator but not iOS 8, although it has been suggested it will work on a physical iOS 8 device.

Isocrates answered 21/9, 2014 at 17:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.