我試圖在兩個單元(Subject「feedback」和「feedback2」)中實現MFMailComposeViewController()。MFMailComposeViewController not called
當我選擇每個單元格時,「反饋」運行良好,但「feedback2」未被調用。
這似乎並不困難的問題,但我覺得很難解決這個問題。
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
if indexPath.row == 0 {
let message = "hey download this app"
let shareView = UIActivityViewController(activityItems: [message], applicationActivities: nil)
self.present(shareView, animated: true, completion: nil)
} else if indexPath.row == 1 {
let mailCompose = MFMailComposeViewController()
mailCompose.mailComposeDelegate = self
mailCompose.setToRecipients(["gmail.com"])
mailCompose.setSubject("feedback")
mailCompose.setMessageBody("text", isHTML: false)
if MFMailComposeViewController.canSendMail()
{
self.present(mailCompose, animated: true, completion: nil)
} else if indexPath.row == 2 {
let mailCompose = MFMailComposeViewController()
mailCompose.mailComposeDelegate = self
mailCompose.setToRecipients(["[email protected]"])
mailCompose.setSubject("feedback2")
mailCompose.setMessageBody("text", isHTML: false)
if MFMailComposeViewController.canSendMail()
{
self.present(mailCompose, animated: true, completion: nil)
}
else{
print("error...!")
}
}
func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
controller.dismiss(animated: true, completion: nil)
}
@ risa18任何錯誤,我想你在呼喚indexPath.row == 2在indexPath.row == 1裏面。 –