使用 UIActivityViewController 在 iPad 上清空电子邮件正文
Posted
技术标签:
【中文标题】使用 UIActivityViewController 在 iPad 上清空电子邮件正文【英文标题】:Empty email body on iPad using UIActivityViewController 【发布时间】:2015-06-28 23:38:48 【问题描述】:我正在使用 UIActivityViewController
将共享添加到我的应用程序。一切都在 iPhone 上按预期工作,但在 iPad 上,邮件视图控制器在点击“UIActivityViewController”的电子邮件图标后被调出,但电子邮件正文未设置(使用text1
)并且电子邮件视图控制器处于非活动状态并且不允许用户输入收件人。
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)
【问题讨论】:
【参考方案1】:事实证明,重新启动 iPad 解决了这个问题。
【讨论】:
疯了,但这里是一样的,关闭再打开代码开始工作。【参考方案2】:嘿,试试这样的
-
导入消息库
将邮件委托添加到类中
撰写并发送您的信息
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)
【讨论】:
谢谢,但想法是使用 UIActivityViewControl,它允许使用相同的控制器与邮件、消息、Facebook、Twitter 等共享。以上是关于使用 UIActivityViewController 在 iPad 上清空电子邮件正文的主要内容,如果未能解决你的问题,请参考以下文章
在使用加载数据流步骤的猪中,使用(使用 PigStorage)和不使用它有啥区别?