我正在尝试实现发送邮件代码,但是出现以下错误:

Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior

这是我的代码段:
    if MFMailComposeViewController.canSendMail() {
        let mail = MFMailComposeViewController()
        mail.mailComposeDelegate = self
        mail.setToRecipients(["@gmail.com"])
        presentViewController(mail, animated: true, completion: nil)
    } else {
        // show failure alert
    }

最佳答案

如果您忘记将按钮删除到按钮的另一功能,则可能会发生收到的错误。

关于ios - 不允许在取消分配时尝试加载 View Controller 的 View ,这可能会导致未定义的行为,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33176169/

10-12 02:04