收到电子邮件结果后执行 Segue
PerformSegue after getting an email result
When sending an email:
if MFMailComposeViewController.canSendMail()
{
let mail = MFMailComposeViewController()
mail.mailComposeDelegate = self
// the set to receipient
// is always this email
// since this is the owners email
mail.setSubject("ORDER CONFIRMATION RODEO'S CATERING")
mail.setToRecipients(["rodeoscatering2018@gmail.com"])
mail.setMessageBody( m_information_for_body , isHTML: false)
self.present(mail, animated: true)
}
func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?)
{
// In here I am checking if it is sent
case .sent:
do
{
print("sent")
controller.dismiss(animated: true, completion: nil)
// and then doing a performSegue below...
// performSegue(withIdentifier....)
}
}
我知道这不是标识符的问题,所有的转场都在那里。我看到打印消息。但不幸的是,当电子邮件提示出现时,我按发送,然后电子邮件控制器被关闭(这很好)并将我带到我所在的当前屏幕并显示打印消息,但是 performSegue 没有'不会发生。
我基本上希望它返回到发生 .sent 案例的位置然后返回主页
Swift 4.2 及最新 xCode 10.1
归功于 Willijay:
显示他的评论有效的代码示例:
这将执行以下操作:
- 如果邮件已发送,那么当用户在警报上按 'Ok' 时,我们会显示一个警报,说明它已成功,然后 performSegue() 到主屏幕:
func go_back_home() -> Void
{
let title = "Confirmation Order Status"
let message = "Message was sent. Check email for a copy"
let alert = UIAlertController(
title: title,
message: message,
preferredStyle: .alert)
alert.addAction(UIAlertAction(title:"OK", style: .default, handler:
{
action in self.performSegue(withIdentifier: "order_info_back_to_home_page", sender: self)
}))
self.present(alert, animated: true)
}
那么我们使用go_back_home()函数的方式是这样的:
func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?)
{
// In here I am checking if it is sent
case .sent:
do
{
print("sent")
controller.dismiss(animated: true, completion: go_back_home)
}
}
When sending an email:
if MFMailComposeViewController.canSendMail()
{
let mail = MFMailComposeViewController()
mail.mailComposeDelegate = self
// the set to receipient
// is always this email
// since this is the owners email
mail.setSubject("ORDER CONFIRMATION RODEO'S CATERING")
mail.setToRecipients(["rodeoscatering2018@gmail.com"])
mail.setMessageBody( m_information_for_body , isHTML: false)
self.present(mail, animated: true)
}
func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?)
{
// In here I am checking if it is sent
case .sent:
do
{
print("sent")
controller.dismiss(animated: true, completion: nil)
// and then doing a performSegue below...
// performSegue(withIdentifier....)
}
}
我知道这不是标识符的问题,所有的转场都在那里。我看到打印消息。但不幸的是,当电子邮件提示出现时,我按发送,然后电子邮件控制器被关闭(这很好)并将我带到我所在的当前屏幕并显示打印消息,但是 performSegue 没有'不会发生。
我基本上希望它返回到发生 .sent 案例的位置然后返回主页
Swift 4.2 及最新 xCode 10.1
归功于 Willijay:
显示他的评论有效的代码示例: 这将执行以下操作: - 如果邮件已发送,那么当用户在警报上按 'Ok' 时,我们会显示一个警报,说明它已成功,然后 performSegue() 到主屏幕:
func go_back_home() -> Void
{
let title = "Confirmation Order Status"
let message = "Message was sent. Check email for a copy"
let alert = UIAlertController(
title: title,
message: message,
preferredStyle: .alert)
alert.addAction(UIAlertAction(title:"OK", style: .default, handler:
{
action in self.performSegue(withIdentifier: "order_info_back_to_home_page", sender: self)
}))
self.present(alert, animated: true)
}
那么我们使用go_back_home()函数的方式是这样的:
func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?)
{
// In here I am checking if it is sent
case .sent:
do
{
print("sent")
controller.dismiss(animated: true, completion: go_back_home)
}
}