使用UIActivityViewController在iPad上清空电子邮件正文

时间:2015-06-28 23:38:48

标签: ios ipad email 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)

2 个答案:

答案 0 :(得分:0)

嘿,尝试这样的事情

  1. 导入消息lib
  2. 将邮件委托添加到班级
  3. 撰写并发送您的信息

    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)
        }
    

答案 1 :(得分:0)

事实证明重启iPad可以解决问题。