Ios Swift 3中MFMailcomposeviewcontroller出错
我对Swift比较陌生,需要帮助解决我不断遇到的这个错误。我正试图在此视图控制器上打开一封电子邮件,但它不断向我显示错误: “试图呈现视图不在中的MFMailcomposeviewcontroller 窗口层次结构” 任何帮助都将不胜感激。谢谢Ios Swift 3中MFMailcomposeviewcontroller出错,ios,swift,xcode,Ios,Swift,Xcode,我对Swift比较陌生,需要帮助解决我不断遇到的这个错误。我正试图在此视图控制器上打开一封电子邮件,但它不断向我显示错误: “试图呈现视图不在中的MFMailcomposeviewcontroller 窗口层次结构” 任何帮助都将不胜感激。谢谢 @IBOutlet var label2: UILabel! @IBOutlet var pickerview2: UIPickerView! let reason = ["Busy - General","Filming","Editing","Co
@IBOutlet var label2: UILabel!
@IBOutlet var pickerview2: UIPickerView!
let reason = ["Busy - General","Filming","Editing","Computer Task","Helping","Getting Set Up"]
func numberOfComponents(in pickerView: UIPickerView) -> Int {
return 1
}
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
return reason[row]
}
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return reason.count
}
@IBAction func sendButton(_ sender: Any) {
self.performSegue(withIdentifier: "reasontosent", sender: self)
let toRecipients = ["jvfdjnnvf@gmail.com"]
let mc: MFMailComposeViewController = MFMailComposeViewController()
mc.mailComposeDelegate = self
mc.setToRecipients(toRecipients)
mc.setSubject("Media Team Task")
mc.setMessageBody("Name: Placeholder", isHTML: false)
//make it like this: mc.setMessageBody("Name: \(nameField.text!)", isHTML: <#T##Bool#>)
controller.presentViewController(mc, animated: true, completion: nil)
}
func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
controller.dismiss(animated: true, completion: nil);
}
@IBOutlet var label2:UILabel!
@IBOUTLE var PICKERVEW2:UIPICKERVEW!
let reason=[“忙-一般”、“拍摄”、“编辑”、“计算机任务”、“帮助”、“设置”]
func numberOfComponents(在pickerView:UIPickerView中)->Int{
返回1
}
func pickerView(pickerView:UIPickerView,titleForRow行:Int,forComponent组件:Int)->String?{
返回原因[行]
}
func pickerView(pickerView:UIPickerView,numberOfRowsInComponent:Int)->Int{
返回原因。计数
}
@iAction func sendButton(\发送方:任意){
self.performsgue(标识符为“reasontosent”,发送方为self)
让toRecipients=[”jvfdjnnvf@gmail.com"]
设mc:MFMailComposeViewController=MFMailComposeViewController()
mc.mailComposeDelegate=self
mc.setToRecipients(toRecipients)
mc.setSubject(“媒体团队任务”)
mc.setMessageBody(“名称:占位符”,isHTML:false)
//如下所示:mc.setMessageBody(“Name:\(nameField.text!)”,isHTML:)
controller.presentViewController(mc,动画:true,完成:nil)
}
func-mailcomosecontroller(u控制器:mfmailcomoseviewcontroller,didFinishWith结果:MFMailComposeResult,错误:error?){
控制器。解除(动画:真,完成:零);
}
您试图通过使用控制器来显示/取消mc
,这是什么?我使用了一个教程,结束代码是控制器。presentViewController(mc,动画:true,完成:nil)显示一个错误,“使用未识别的解析程序“控制器”。仅用户presentViewController而不是controller.presentViewController