我想在我点击发送或取消我的电子邮件弹出窗口之后立即显示警报控制器,显示我的邮件是否已发送,我已设法在发送邮件之前显示警报控制器但不是AFTER ......:
func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
switch result {
case .cancelled:
let alertController = UIAlertController.init(title: "Cancelled", message: "Send Email has been cancelled", preferredStyle: .alert)
alertController.addAction(UIAlertAction.init(title: "Ok", style: .default, handler: { (alertAction) in
controller.dismiss(animated: true, completion: nil)
}))
controller.present(alertController, animated: true, completion: nil)
case .sent:
let alertController = UIAlertController.init(title: "Sent", message: "Message Sent Successfully", preferredStyle: .alert)
alertController.addAction(UIAlertAction.init(title: "Ok", style: .default, handler: { (alertAction) in
controller.dismiss(animated: true, completion: nil)
}))
default:
break;
}
这就是我试过的
答案 0 :(得分:0)
问题是你试图使用一个弹出窗口的控制器加上它会被解雇,你可以试试
UIApplication.shared.keyWindow?.rootViewController?.present(alertController, animated: true, completion: nil)