ios - Swift:如何确定何时发送电子邮件以更新 TableView ?

标签 ios swift email swift3 mfmailcomposer

我正在创建一个应用程序,允许用户通过 MFMailComposer 发送简单的电子邮件。我已经配置了该部分,但我想弄清楚,一旦发送电子邮件,如何更新显示“电子邮件已发送”之类的内容并可能带有时间戳的表格 View ? 到目前为止,我有一个字符串数组,应该存储发送的电子邮件的数据:

var emailSent = [String]()

任何建议或帮助将不胜感激!

最佳答案

您可以在 tableview Controller 中创建一个名为 selectedCellIndexPathRow 的属性,您可以在 didSelectRowAtIndexPath 方法中设置该属性:

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    selectedCellIndexPathRow = indexPath.row
    //Open your MailComposeViewController
}

然后,电子邮件发送后,您可以执行以下操作:

func mailComposeController(controller: MFMailComposeViewController, didFinishWithResult result: MFMailComposeResult, error: NSError?) {
    if result.rawValue == MFMailComposeResult.Sent.rawValue {
        emailSent[selectedCellIndexPathRow] = true
        tableView.reloadData()
    }

    // Dismiss the mail compose view controller.
    controller.dismissViewControllerAnimated(true, completion: nil)
}

关于ios - Swift:如何确定何时发送电子邮件以更新 TableView ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40114148/

相关文章:

windows - 从批处理脚本发送电子邮件。布拉特不起作用

email - DB2 如何从存储过程发送电子邮件?

MacOSX : new mail with attachment

ios - 计算航向 iOS mapkit

ios - 在 podfile 错误中更新 Alamofire

ios - UICollectionView 中标题 View 的高度

ios - 在 Swift 的自定义 UIView 子类中通过 UIAppearance 设置文本属性

ios - xamarin iOS : How to show the audio amplitude of the voice when recording

objective-c - 用于 iOS ARC 问题的 BWDB SQLite 包装器

ios - CloudKit 中的 CKNotification 和 CKQueryNotification 有什么区别?