在设置如下的联系论坛后,我收到以下错误。有没有改变/贬值的Xcode没有捕获或我今天早上只是累了?
“实例方法'mailComposeController(controller:didFinishWithResult:error :)'几乎匹配协议'MFMailComposeViewControllerDelegate'的可选要求'mailComposeController(_:didFinishWith:error :)'” - 第46行
“候选人有非匹配类型”(MFMailComposeViewController,MFMailComposeResult,NSError?) - >()'“ - 第46行
“make'mailComposeController(controller:didFinishWithResult:error :)'私有化,以此来警告” - 第46行
“使用未解析的标识符'MFMailComposeCancelled” - 第50行
“使用未解析的标识符'MFMailComposeResultFailed'” - 第53行
“使用未解析的标识符'MFMailComposeResultSaved'” - 第56行
“使用未解析的标识符'MFMailComposeResultSent'” - 第59行
import Foundation
import MessageUI
class Contact : UIViewController, MFMailComposeViewControllerDelegate {
@IBOutlet weak var WOLMenu: UIBarButtonItem!
@IBOutlet var NameField: UITextField!
@IBOutlet var EmailField: UITextField!
@IBOutlet var PhoneField: UITextField!
@IBOutlet var MessageField: UITextField!
override func viewDidLoad() {
self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
@IBAction func Send(sender: AnyObject) {
let toRecipients = ["s jobs @ apple . com"]
let mc: MFMailComposeViewController = MFMailComposeViewController()
mc.mailComposeDelegate = self
mc.setToRecipients(toRecipients)
mc.setSubject(NameField.text!)
mc.setMessageBody("Name: \(NameField.text!) \n\nEmail: \(EmailField.text!) \n\nPhone: \(PhoneField.text!) \n\nMessage: \(MessageField.text!)", isHTML: false)
self.present(mc, animated: true, completion: nil)
}
func mailComposeController(controller: MFMailComposeViewController,
didFinishWithResult result: MFMailComposeResult, error: NSError?) {
switch result.rawValue {
case MFMailComposeCancelled.rawValue:
print("CANCELED")
case MFMailComposeResultFailed.rawValue:
print("Failed")
case MFMailComposeResultSaved.rawValue:
print("Saved")
case MFMailComposeResultSent.rawValue:
print("Sent")
default:
break
controller.dismiss(animated: true, completion: nil)
}
}
override var prefersStatusBarHidden: Bool {
return true
}
}
此外,代码来自Apple的文档必须更新 MFMailComposeViewController Documention