Gmail应用程序将PDF转换为电子邮件无法使用PDFKIT在UIACtivityViewController上正常工作
当您与uiactivityViewController共享PDF时,遇到了一些PDFKIT问题,而Gmail不会正确地转换PDF文件,它在其他每个平台(邮件应用程序,Yahoo Mail,Outlook等)上均可正常工作
if let pdfData = document.dataRepresentation() {
print("Ran")
let objectsToShare = [pdfData]
let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
activityVC.popoverPresentationController?.sourceView = self.shareBtn
//activityVC.popoverPresentationController?.sourceRect = CGRect(x: 200, y: 200, width: 100, height: 100)
activityVC.popoverPresentationController?.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.midY,width: 0,height: 0)
//self.presentedViewController?.present(activityVC, animated: true)
print("Print presented view")
activityVC.isModalInPresentation = true
self.present(activityVC, animated: true, completion: nil)
}
。 net/qdayn.jpg“ rel =” nofollow noreferrer“>
解决方案:
let temporaryFolder = FileManager.default.temporaryDirectory
let fileName = "document.pdf" //whatever you want to call the file name
let temporaryFileURL = temporaryFolder.appendingPathComponent(fileName)
print("print: ", temporaryFileURL.path)
let activityVC = UIActivityViewController(activityItems: [temporaryFileURL], applicationActivities: nil)
activityVC.popoverPresentationController?.sourceView = self.shareBtn
//activityVC.popoverPresentationController?.sourceRect = CGRect(x: 200, y: 200, width: 100, height: 100)
activityVC.popoverPresentationController?.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.midY,width: 0,height: 0)
//self.presentedViewController?.present(activityVC, animated: true)
print("Print presented view")
activityVC.isModalInPresentation = true
self.present(activityVC, animated: true, completion: nil)
Ran into some pdfkit issues when you share a PDF with UIActivityViewController and Gmail doesnt convert the PDF file properly it works on every other platform (Mail app, Yahoo Mail, Outlook, etc)
if let pdfData = document.dataRepresentation() {
print("Ran")
let objectsToShare = [pdfData]
let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
activityVC.popoverPresentationController?.sourceView = self.shareBtn
//activityVC.popoverPresentationController?.sourceRect = CGRect(x: 200, y: 200, width: 100, height: 100)
activityVC.popoverPresentationController?.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.midY,width: 0,height: 0)
//self.presentedViewController?.present(activityVC, animated: true)
print("Print presented view")
activityVC.isModalInPresentation = true
self.present(activityVC, animated: true, completion: nil)
}
SOLUTION:
let temporaryFolder = FileManager.default.temporaryDirectory
let fileName = "document.pdf" //whatever you want to call the file name
let temporaryFileURL = temporaryFolder.appendingPathComponent(fileName)
print("print: ", temporaryFileURL.path)
let activityVC = UIActivityViewController(activityItems: [temporaryFileURL], applicationActivities: nil)
activityVC.popoverPresentationController?.sourceView = self.shareBtn
//activityVC.popoverPresentationController?.sourceRect = CGRect(x: 200, y: 200, width: 100, height: 100)
activityVC.popoverPresentationController?.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.midY,width: 0,height: 0)
//self.presentedViewController?.present(activityVC, animated: true)
print("Print presented view")
activityVC.isModalInPresentation = true
self.present(activityVC, animated: true, completion: nil)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论