【发布时间】:2017-12-23 22:35:56
【问题描述】:
我制作了一个可以拍照的相机应用程序,一旦拍照,我点击一个 ui 按钮来撰写一封带有该图像作为附件的邮件。即使在撰写电子邮件时可以看到附件中的图像文件,一切似乎都运行良好。当点击“发送”并打开我的电子邮件 ID 时,我没有收到任何新的收件箱。这是代码
func sendEmail() {
let composeVC = MFMailComposeViewController()
composeVC.mailComposeDelegate = self
// Configure the fields of the interface.
composeVC.setToRecipients([email])
composeVC.setSubject("Hello!")
composeVC.setMessageBody("Hello this is my message body!", isHTML: false)
let imageData: NSData = UIImagePNGRepresentation(pickedImage.image!)! as NSData
composeVC.addAttachmentData(imageData as Data, mimeType: "image/jpeg", fileName: name)
// Present the view controller modally.
self.present(composeVC, animated: true, completion: nil)
}
func mailComposeController(_ controller: MFMailComposeViewController,
didFinishWith result: MFMailComposeResult, error: Error?) {
controller.dismiss(animated: true, completion: nil)
}
【问题讨论】:
-
检查您的发件箱。
-
那里什么也没有。
-
发现问题。不允许“移动数据”访问我的 iOS 设备上的邮件应用程序。
-
如果您认为它会帮助他人,可以将其作为答案发布,或者删除您的问题。
标签: ios swift mfmailcomposeviewcontroller