Simply trying to allow the user to send emails. At the moment when the button "contact" is clicked, it takes me to a black screen rather than displaying the mailComposers.
The debugger responds with
2018-05-14 11:10:59.465952-0400 App[2333:757177] Failed to set (keyPath) user defined inspected property on (UIButton): [ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key keyPath.
However, that only occurs when sliding the menu from left to right using the SWReveal function. When removing the code from below, all the other functionalities work properly. Its only when using the code from below that gives me the black screen at the moment "button contact" is pressed.
import Foundation
import UIKit
import MessageUI
class SendEmailVC: MFMailComposeViewController, MFMailComposeViewControllerDelegate
{
@IBAction func Send_Tapped(_ sender: Any)
{
if MFMailComposeViewController.canSendMail()
{
contact()
let mailComposeViewController = configureMailController() //FIXED √
self.present(mailComposeViewController, animated: true, completion: nil)
}
else
{
showMailError()
}
}
func configureMailController() -> MFMailComposeViewController
{
let mailComposerVC = MFMailComposeViewController()
mailComposerVC.mailComposeDelegate = self
mailComposerVC.setToRecipients(["testing@gmail.com"])
mailComposerVC.setSubject("Hello")
mailComposerVC.setMessageBody("How are you doing?", isHTML: false)
return mailComposerVC
}
/*
* DON'T EDIT THE CODE BELOW.
*/
func showMailError()
{
let sendMailErrorAlert = UIAlertController(title: "Email failed to send", message: "Your device fail to send the email", preferredStyle: .alert)
let dismiss = UIAlertAction(title: "Dale", style: .default, handler: nil)
sendMailErrorAlert.addAction(dismiss)
self.present(sendMailErrorAlert, animated: true, completion: nil)
}
func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?)
{
controller.dismiss(animated: true, completion: nil)
}
}