我在使用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