gpt4 book ai didi

ios - 如何使用 swift 使用 UIActivityViewController 仅通过电子邮件共享

转载 作者:搜寻专家 更新时间:2023-10-31 08:33:25 26 4
gpt4 key购买 nike

 let activityViewController = UIActivityViewController (activityItems: contentArray, applicationActivities:nil)
if let popoverController = activityViewController.popoverPresentationController {
popoverController.sourceView = sender

}
self.presentViewController(activityViewController, animated: true, completion: nil)

所以基本上我只想通过邮件分享内容,我不想显示消息选项。你能帮我解决这个问题吗?另外我想通过代码设置邮件的主题

最佳答案

只需添加 excludedActivityTypes 即可删除除电子邮件以外的所有其他事件

yourActivityViewController.excludedActivityTypes = [ UIActivityTypePostToFacebook, UIActivityTypePostToTwitter, UIActivityTypePostToWeibo, UIActivityTypeMessage, UIActivityTypePrint, UIActivityTypeCopyToPasteboard,UIActivityTypeAssignToContact,UIActivityTypeSaveToCameraRoll,UIActivityTypeAddToReadingList, UIActivityTypePostToFlickr, UIActivityTypePostToVimeo,UIActivityTypePostToTencentWeibo,UIActivityTypeAirDrop]

添加主题

 yourActivityViewController.setValue("Your email Subject" , forKey: "subject") ;

建议:-您还可以使用 MFMailComposeViewController 发送电子邮件

 var picker = MFMailComposeViewController()
picker.mailComposeDelegate = self
picker.setSubject(subject.text)
picker.setMessageBody(body.text, isHTML: true)

presentViewController(picker, animated: true, completion: nil)

更多引用:- How do I use UIActivityItemProvider to send an email with attachment with UIActivityViewController?

iOS 8 - Disable iCloud Photo Sharing Activity

关于ios - 如何使用 swift 使用 UIActivityViewController 仅通过电子邮件共享,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32387056/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com