MailCompose with iPhone 5

I am trying to send email through my application and I am 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 get a strange error when the create screen appears on my iPhone 5, without a body (although the body was installed above). I cannot see the cursor if I click on any field and therefore cannot edit, and the submit button is inactive. And when I fire 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 iPhone 4s, iPhone 4 and on Simulator, it works fine. I also tested it on another iPhone 5 and it works great. The body is there, and I can send an email, etc.

Is there anything else I can skip? I have two email accounts associated with the mail on my phone, so it canSendMailshould work ...

+5
1

. , , Apple. , .

+13

All Articles