点击“电子邮件”按钮时无法识别选择器错误

时间:2017-03-26 17:08:39

标签: ios unrecognized-selector

class ContactViewController: UIViewController, MFMailComposeViewControllerDelegate {

override func viewDidLoad() {
    super.viewDidLoad()
}

@IBAction func emailSenden(_ sender: Any) {

    if !MFMailComposeViewController.canSendMail() {
        print("Mail services are not available")
        return
    } else {
            let mail = MFMailComposeViewController()
            mail.mailComposeDelegate = self
            mail.setToRecipients(["someone@example.com"])
            mail.setSubject("Message to you")
            mail.setMessageBody("Hallo,\n", isHTML: false)

            present(mail, animated: true, completion: nil)

            mail.dismiss(animated: true, completion: nil)
            }

    }
}

这是我的代码。问题是,每次我想在我的应用程序中运行它时,我都会收到此错误: ***由于未捕获的异常终止应用程序' NSInvalidArgumentException',原因:' - [My_App.ContactViewController电子邮件:]:无法识别的选择器发送到实例0x100b22430'

你能帮帮我吗?

0 个答案:

没有答案