MFMailComposeViewControllerDelegate not being called

前端 未结 4 1468
北恋
北恋 2021-01-20 02:08

I realize this question has been inexactly asked around, but I haven\'t been able to find an answer to my problem.

I have a UITableViewController with static cells.

相关标签:
4条回答
  • 2021-01-20 02:39
    mailCVP.delegate = self
    mailCVP = configureMailComposeVC()
    

    This code sets the delegate but then creates a new instance, which doesn't have a delegate...

    Note that there is also no point in creating the VC instance if MFMailComposeViewController.canSendMail returns false.

    0 讨论(0)
  • 2021-01-20 02:51

    Make sure you use

    controller.mailComposeDelegate = self
    

    Not this one

    controller.delegate = self
    
    0 讨论(0)
  • 2021-01-20 02:51

    First of all use

    mailCVP.mailComposeDelegate = self
    

    instead of

    mailCVP.delegate = self
    

    Moreover, in case of Swift 3, delegate method is somehow updated which is:

    func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?){
        controller.dismiss(animated: true, completion: nil)
    }
    
    0 讨论(0)
  • 2021-01-20 03:01

    MFMailComposeViewController is a subclass of UINavigationController, which already has a delegate property to handle navigation changes.

    MFMailComposeViewController has another property called mailComposeDelegate, which is the property you are looking for.

    Also, you should create the controller before setting the delegate.

    0 讨论(0)
提交回复
热议问题