MFMailComposeViewController not editable in iOS 8 Xcode 6

I am using the following code to show an email sheet. The sheet appears, but I cannot edit the theme, body. I can't even hit the cancel or submit buttons. Here is my implementation:

class PeopleListTableViewController: UITableViewController,SWTableViewCellDelegate,UINavigationControllerDelegate,MFMailComposeViewControllerDelegate, NSXMLParserDelegate {

 func showEmailSheet(person :Person) {

        if MFMailComposeViewController.canSendMail() {

            let mailViewController = MFMailComposeViewController()
            mailViewController.mailComposeDelegate = self


            self.presentViewController(mailViewController, animated: true, completion: nil)



What am I doing wrong?


source to share

3 answers

Here is a working code from one of my projects. Make sure to work with the form on an iOS device, not in a simulator.

import UIKit
import MessageUI

class ViewController: UIViewController, MFMailComposeViewControllerDelegate {
    @IBAction func launchEmail(sender: AnyObject) {

        var emailTitle = "Feedback"
        var messageBody = "Feature request or bug report?"
        var toRecipents = [""]
        var mc: MFMailComposeViewController = MFMailComposeViewController()
        mc.mailComposeDelegate = self
        mc.setMessageBody(messageBody, isHTML: false)

        self.presentViewController(mc, animated: true, completion: nil)

    func mailComposeController(controller:MFMailComposeViewController, didFinishWithResult result:MFMailComposeResult, error:NSError) {
        switch result.value {
        case MFMailComposeResultCancelled.value:
            println("Mail cancelled")
        case MFMailComposeResultSaved.value:
            println("Mail saved")
        case MFMailComposeResultSent.value:
            println("Mail sent")
        case MFMailComposeResultFailed.value:
            println("Mail sent failure: %@", [error.localizedDescription])
        self.dismissViewControllerAnimated(true, completion: nil)




I have the same problem in Xcode6 and iOS8.

However, I noticed that this is an emulator issue. The following code works on iOS8, but only on a device (not an emulator)!

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

    messageContent=[NSString stringWithFormat:@"Bla bla"];

    [composer setSubject:@"The subject"];
    [composer setMessageBody:messageContent isHTML:NO];
    [composer setToRecipients:[NSArray arrayWithObject:[NSString stringWithFormat:@""]]];

    [composer setCcRecipients:nil];
    [composer setBccRecipients:nil];
    [composer setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];

    [self presentViewController:composer animated:YES completion:nil];




I came up with a simple solution like this:

//outlet & btns
@IBOutlet weak var forgotEmail: UITextField!

@IBAction func resetPW(sender: AnyObject) {
    // send email
    var mailer = MFMailComposeViewController()
    mailer.mailComposeDelegate = self
    mailer.setSubject("Forgot Password")

    presentViewController(mailer, animated:true, completion: nil)



PS: "setToRecipients" only works on real device, not simulator!



All Articles