使用 UIActivityViewController 在 iPad 上清空电子邮件正文
Empty email body on iPad using UIActivityViewController
我正在使用 UIActivityViewController
将共享添加到我的应用程序。一切都按预期在 iPhone 上运行,但在 iPad 上,邮件视图控制器在点击 'UIActivityViewController' 的电子邮件图标后出现,但电子邮件正文未设置(与text1
) 并且电子邮件 viewController 处于非活动状态,不允许用户输入收件人。
let text1 = "this is the body of the email"
self.finalizeDocument()
let controller = UIActivityViewController(activityItems: [text1], applicationActivities: nil)
controller.setValue("Siged document is attached", forKey: "subject")
if let ppc = controller.popoverPresentationController {
ppc.barButtonItem = self.shareButton!
}
self.presentViewController(controller, animated: true, completion: nil)
嘿,试试这样的东西
- 导入消息库
- 将邮件委托添加到 class
撰写并发送您的消息
import MessageUI
class ViewController: UIViewController, MFMailComposeViewControllerDelegate{
func someAwesomeFunction(){
var subjectText = “ OMG a subject”
var bodtText = “ YOLO”
var picker = MFMailComposeViewController()
picker.mailComposeDelegate = self
picker.setSubject(subjectText)
picker.setMessageBody(bodtText, isHTML: true)
presentViewController(picker, animated: true, completion: nil)
}
事实证明,重新启动 iPad 解决了问题。
我正在使用 UIActivityViewController
将共享添加到我的应用程序。一切都按预期在 iPhone 上运行,但在 iPad 上,邮件视图控制器在点击 'UIActivityViewController' 的电子邮件图标后出现,但电子邮件正文未设置(与text1
) 并且电子邮件 viewController 处于非活动状态,不允许用户输入收件人。
let text1 = "this is the body of the email"
self.finalizeDocument()
let controller = UIActivityViewController(activityItems: [text1], applicationActivities: nil)
controller.setValue("Siged document is attached", forKey: "subject")
if let ppc = controller.popoverPresentationController {
ppc.barButtonItem = self.shareButton!
}
self.presentViewController(controller, animated: true, completion: nil)
嘿,试试这样的东西
- 导入消息库
- 将邮件委托添加到 class
撰写并发送您的消息
import MessageUI class ViewController: UIViewController, MFMailComposeViewControllerDelegate{ func someAwesomeFunction(){ var subjectText = “ OMG a subject” var bodtText = “ YOLO” var picker = MFMailComposeViewController() picker.mailComposeDelegate = self picker.setSubject(subjectText) picker.setMessageBody(bodtText, isHTML: true) presentViewController(picker, animated: true, completion: nil) }
事实证明,重新启动 iPad 解决了问题。