Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MailCompose with iPhone 5

Tags:

ios

I'm trying to send emails through my application, and i'm using the following code:

        if ([MFMailComposeViewController canSendMail]) {
            MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
            controller.mailComposeDelegate = self;

            NSString *subject = @"";
            NSString *body = @"";

            [controller setSubject:subject];
            [controller setMessageBody:body isHTML:YES];

            [self presentModalViewController:controller animated:YES];

        } else {
            NSString *message = @"Error opening mail, please make sure you have an email account setup";
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Oops" message:message delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
            [alert show];
        }

I'm getting a weird error where on my iPhone 5, the compose screen pops up, with no body (although the body was set above). I"m not able to see a cursor if I click on any box and therefore can't edit, and the send button is non-clickable. And when I dismiss the screen I get the following:

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

However, when I test this on an iPhone 4s, iPhone 4, and on the Simulator--it works fine. I also tested it on another iPhone 5 and it works fine. The body is there, and I can send an email etc.

Is there anything else I may be missing? I have two email accounts associated with mail on my phone, so therefore the canSendMail should work...

like image 709
KVISH Avatar asked Jan 23 '13 21:01

KVISH


1 Answers

Try to use the compose dialog in other apps. If you don't have another app in mind to try this with, you can download and compile Apple's Sample. If it does not work in other apps, try restarting your device.

like image 134
Mathew Avatar answered Oct 06 '22 00:10

Mathew