我正在尝试通过以下方式在iOS中发送电子邮件:
var picker = MFMailComposeViewController()
picker.mailComposeDelegate = self
picker.setSubject("Mic Data")
var messageBody = NSMutableString()
for var index = 0; index<array.count; index++ {
messageBody.appendString(String(format: "%@\n", arguments: [array.objectAtIndex(index) as! String]))
}
picker.setMessageBody(messageBody as String, isHTML: false)
presentViewController(picker, animated: true, completion: nil)
但是我在
picker.mailComposeDelegate = self
行上出现错误。但它应该起作用。我已经通过class MainTableViewController: UITableViewController, MFMessageComposeViewControllerDelegate
设置了委托,并使用了委托方法:func messageComposeViewController(controller: MFMessageComposeViewController!, didFinishWithResult result: MessageComposeResult) {
self.dismissViewControllerAnimated(true, completion: nil)
}
我究竟做错了什么?
最佳答案
您在类中添加了MFMessageComposeViewControllerDelegate
而不是MFMailComposeViewControllerDelegate
。容易犯的错误。
关于ios - 无法将类型“MyClass”的值分配给类型“MFMailComposeViewControllerDelegate!”!,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29496773/