24

The situation is the MFMailComposeViewController was going to be presented. I saw it was presented half-way done, but then it got dismissed.

This is the error:

_serviceViewControllerReady:error: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "The operation couldn’t be completed. (_UIViewServiceInterfaceErrorDomain error 3.)"

This is my source code to present the MFMailComposeViewController:

-(void) MailExecute {
    if ([MFMailComposeViewController canSendMail]) 
    {
        MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];   
        mailViewController.mailComposeDelegate = self;
        [mailViewController setSubject:NSLocalizedString(@"Check this new look", @"")];
        [mailViewController setMessageBody: @"my new look" isHTML:YES];

        [self presentModalViewController:mailViewController animated:YES];

        [mailViewController release];
    }
    else 
    {
        UIAlertView *alertInternal = [[UIAlertView alloc]
                                      initWithTitle: NSLocalizedString(@"Notification", @"")
                                      message: NSLocalizedString(@"You have not configured your e-mail client.", @"")
                                      delegate: nil
                                      cancelButtonTitle:NSLocalizedString(@"OK", @"")
                                      otherButtonTitles:nil];
        [alertInternal show];
        [alertInternal release];
    }
}

The weird point is that sometimes it happens, sometimes it doesn't. Please help me on this! I spend almost 1 working day to resolve this but no succeed.

Daij-Djan
  • 49,552
  • 17
  • 113
  • 135
Truong
  • 243
  • 1
  • 2
  • 5
  • 1
    you go this exception while your app on Device or Simulator? – DD_ Dec 04 '12 at 05:52
  • 1
    Most likely not related to mailComposeView, but UIView in general: got similar error note with quickLook. Still debugging... – JOM Dec 04 '12 at 13:58
  • Hi JOM, did you find out anything new on this error? – Truong Dec 06 '12 at 09:24
  • Have you added the MessageUI.framework? – DenVog Dec 21 '12 at 02:16
  • Can you also please show your `MFMailComposeViewController` delegate methods? – BufferStack Dec 25 '12 at 09:10
  • Assuming one answer solved this or you found a solution, can you accept or enter it to close the open question? – David H May 05 '13 at 12:56
  • 1
    Hey, was wondering if you managed to solve this. I am having this problem too but only is some circumstances and I cannot reproduce it! – Ants Jun 15 '13 at 00:07
  • I encountered the same error message with QuickLook, and the problem was that I was loading a PDF with a width of 1300+ pixels. When I rotated the pdf so that its width was ~700px, it worked fine. – jankins Nov 14 '13 at 19:07

9 Answers9

3

This problem can occur when displaying a remote view controller -- a view controller run in another process -- as indicated by the UIViewService reference in the error message.

I've had this problem when displaying an SKStoreProductViewController, which is also a remote view controller. I'm not sure what the root cause is; the only thing that seemed to trigger it for me was presenting the view controller repeatedly.

For the SKStoreProductViewController I was able to check for this error in the completion block of the loadProductWithParameters:completionBlock: method. Does the MFMailComposeViewControllerDelegate give you a callback with an error about this? It may be that all you can do is listen for this error and show an error message to the user.

We should both probably file an apple radar about this.

MaxGabriel
  • 7,617
  • 4
  • 35
  • 82
2

Your code looks correct, and as stated the error message strongly suggests this has something to do with UIView proper (not MFMail specifically). The problem almost surely lies somewhere elsewhere within your code, and might be challenging to troubleshoot.

Some things to look for:

  1. Other animations or view controller transitions/dismissals happening simultaneously or incorrectly (possibly like this)
  2. Release/retain issues, of course

If none of that seems like the fix, try commenting-out everything else happening in the view controller that calls this method and see if it works then.

If you still can't get it working, present the simplest version you can of failing code so we can troubleshoot further. :)

Community
  • 1
  • 1
toblerpwn
  • 5,415
  • 8
  • 38
  • 46
0

Do you have anything in your viewDidDisappear: or viewWillDisappear methods that would dismiss a view controller?

If not, can you post more of your code for the ViewController that presents the MFMailComposeViewController?

a1phanumeric
  • 814
  • 2
  • 12
  • 29
  • I'm pretty sure there's nothing wrong with viewDidDisappear or viewWillDisappear. But I'm not investigating it anymore so thanks for your help. – Truong Jun 12 '13 at 18:16
  • I'm not investigating this bug anymore. Thanks for your help. – Truong Jun 12 '13 at 18:18
0

I know this is the late reply, but may be help some other.

Just now face the same problem, By resetting the simulator work fine for me for this same issue. Let me know if this helps.

icodebuster
  • 8,890
  • 7
  • 62
  • 65
kttailor4u
  • 21
  • 1
  • 4
0

After I stored the MFMailComposeViewController in a strong property of my class instead of a local variable I could not reproduce the self-dismissing behaviour any more.

0

The issue for me was an incorrect argument when calling the attachment function. If you are having this issue with an email attachment I suggest following the solution found in this thread, as follows:

NSString *path = [self getDatabaseFilePath];
NSData *myData = [NSData dataWithContentsOfFile:path];
[picker addAttachmentData:myData mimeType:@"application/x-sqlite3" fileName:[path lastPathComponent]];
Community
  • 1
  • 1
Tr0yJ
  • 3,274
  • 1
  • 22
  • 30
0

MFMailComposeViewController *mailComposer = [[MFMailComposeViewController alloc]init];

if ([MFMailComposeViewController canSendMail])
{
    mailComposer.mailComposeDelegate = self;
    [mailComposer setToRecipients:[NSArray arrayWithObject:@"support@kapsie.com"] ];
    [mailComposer setSubject:@"Kapsie App Contact Support"];
    [mailComposer setMessageBody:@"Type Your Feedback message here" isHTML:NO];
    [self presentViewController:mailComposer animated:YES completion:nil];
}

Use above code and check it on device.

-1

Use of modelViewController is deprecated in iOS 6 , use

[self presentViewController:mailView animated:YES completion:nil];
Dushyant Singh
  • 721
  • 4
  • 13
-1

I face the same problem and the solution was:

I delete the overall application appearence related code like

[[UILabel appearance]setText:@""] 

and replace with the code

[[UILabel appearanceWhenContainedIn:[self class], nil] setText:@""];

Now it is working fine so be carefull on overall application appearence changes: it might be navigationbar appearance, so and so

arghtype
  • 4,376
  • 11
  • 45
  • 60