我在使用MFMailComposer时遇到了问题。我使用示例Swift Code按照iOS开发人员指南。Swift Dismiss来自幻灯片菜单的邮件控制器
我也采取了看看本网站上的以下类似的问题:
swift - dismissing mail view controller from Sprite Kit
MFMailComposeViewController in Swift does not dismiss
链接框架&库:MessagesUI.framework
import MessageUI
class FHCLLeftMenuViewController: FHBaseViewController,UITableViewDelegate,UITableViewDataSource,MFMailComposeViewControllerDelegate
当我点击我的应用程序的左侧滑动菜单中的支持文本,邮件应用程序出现我写了一封电子邮件,然后点击发送。电子邮件显示在我的收件箱中,但控制器在发送邮件后不会自行解散。当我试图删除草稿时,也会发生这种情况,我必须关闭应用程序并重新启动它。
case kFHCLMenuTagSupport:
//PT DashBoard
if !MFMailComposeViewController.canSendMail() {
print("Mail services are not available")
return
}
let composeVC = MFMailComposeViewController()
composeVC.mailComposeDelegate = self
// Configure the fields of the interface.
composeVC.setToRecipients(["[email protected]"])
composeVC.setSubject("Client Support")
composeVC.setMessageBody("Some text here.", isHTML: false)
// Present the view controller modally.
self.presentViewController(composeVC, animated: true, completion: nil)
func mailComposeController(controller: MFMailComposeViewController,
didFinishWithResult result: MFMailComposeResult, error: NSError?) {
// Check the result or perform other tasks.
// Dismiss the mail compose view controller.
self.dismissViewControllerAnimated(true, completion: nil)
}
break
我也尝试这种变化返回结果相同的应用程序的主仪表板:
case kFHCLMenuTagSupport:
//PT DashBoard
let storyboard = UIStoryboard(name: "Client", bundle: nil)
// Create View Controllers
let mainPage:FHClientDashBoardViewController = storyboard.instantiateViewControllerWithIdentifier("FHClientDashBoardViewController") as! FHClientDashBoardViewController
let mainPageNav = UINavigationController(rootViewController: mainPage)
if !MFMailComposeViewController.canSendMail() {
print("Mail services are not available")
return
}
let composeVC = MFMailComposeViewController()
composeVC.mailComposeDelegate = self
// Configure the fields of the interface.
composeVC.setToRecipients(["[email protected]"])
composeVC.setSubject("Client Support")
composeVC.setMessageBody("Some text here.", isHTML: false)
// Present the view controller modally.
self.presentViewController(composeVC, animated: true, completion: nil)
func mailComposeController(controller: MFMailComposeViewController,
didFinishWithResult result: MFMailComposeResult, error: NSError?) {
// Check the result or perform other tasks.
// Dismiss the mail compose view controller.
// self.dismissViewControllerAnimated(true, completion: nil)
self.mm_drawerController.setCenterViewController(mainPageNav, withCloseAnimation: true, completion: nil)
}
break
任何帮助将不胜感激。
你想关闭'MFMailComposeViewController'或'FHCLLeftMenuViewController'吗? – kabiroberai