iosswiftmfmailcomposer

How to set UserInteractionEnabled to false for recepients in MFMailComposeViewController in swift


I am using MFMailComposeViewController to send feedback from my app.

func configuredMailComposeViewController() -> MFMailComposeViewController {

    let mailComposerVC = MFMailComposeViewController()

    mailComposerVC.mailComposeDelegate = self // Extremely important to set the --mailComposeDelegate-- property, NOT the --delegate-- property
    mailComposerVC.setToRecipients(["info@myCompany.com"])
    mailComposerVC.setSubject("Subject")
    mailComposerVC.setMessageBody("Body", isHTML: false)

    return mailComposerVC
}

In this, I don't want the user to edit the To address. Is this possible?


Solution

  • Unfortunately it's not possible. This small API that doesn't allow to do it.

    I found some old references here in StackOverflow talking about it too:

    How to disable the 'To' field in an In-App email using MFMailComposeViewController?

    How to customize MFMailComposeViewController so that i can make the "to" field as non-editable?