MFMailComposeViewControllerDelegate没有被调用 [英] MFMailComposeViewControllerDelegate not being called

查看:233
本文介绍了MFMailComposeViewControllerDelegate没有被调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题已经被问到了,但是我找不到我的问题的答案.

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

我有一个带有静态单元格的UITableViewController.这些单元之一旨在打开Mail Composer视图,并在用户发送或取消电子邮件后通过委托将其关闭.我的问题是委托方法没有被调用.这是我的代码:

I have a UITableViewController with static cells. One of these cells is meant to open a Mail Composer view, and dismiss it through the delegate after the user sends or cancels the email. My problem is that the delegate method is not being called. Here is my code:

class SideMenuTableViewController: UITableViewController, MFMailComposeViewControllerDelegate, UINavigationControllerDelegate {

 override func viewDidLoad() {
        super.viewDidLoad()

        mailCVP.delegate = self
mailCVP = configureMailComposeVC()
            if MFMailComposeViewController.canSendMail() {
                self.presentViewController(mailCVP, animated: true, completion: nil)
            } else { //..// }
}

func configureMailComposeVC() -> MFMailComposeViewController {
        let mailComposerVC = MFMailComposeViewController()
        mailComposerVC.setToRecipients(["momentosdetora@gmail.com"])
            mailComposerVC.setSubject("Contacto Momentos de Tora")

        return mailComposerVC
    }

func mailComposeController(controller: MFMailComposeViewController, didFinishWithResult result: MFMailComposeResult, error: NSError?) {
        controller.dismissViewControllerAnimated(true, completion: nil)
    }

有人可以发现我做错了什么吗?

Can anybody spot anything I might be doing wrong?

谢谢.

推荐答案

MFMailComposeViewControllerUINavigationController的子类,它已经具有delegate属性来处理导航更改.

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

MFMailComposeViewController具有另一个名为mailComposeDelegate的属性,这是您要查找的属性.

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

此外,您应该在设置委托之前创建控制器.

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

这篇关于MFMailComposeViewControllerDelegate没有被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆