gpt4 book ai didi

ios - PDF 文件无法在 UIDocumentInteractionController 中打开

转载 作者:行者123 更新时间:2023-11-30 12:39:36 24 4
gpt4 key购买 nike

我正在模拟器上工作,没有像adobe这样的应用程序来打开pdf文件....我正在使用UIDocumentInteractionController来打开pdf文件,如下所示。

let url=URL(fileURLWithPath: "/Users/sai/Library/Developer/CoreSimulator/Devices/425D8615-ADEC-4334-A639-C30B1E675EFA/data/Containers/Data/Application/AB3787BF-F6AC-4111-9847-A0FDC4E899F8/tmp/samplepdf.pdf")

print("--------------------------------- str is \(url)")
if (url != nil) {
// Initialize Document Interaction Controller
self.documentInteractionController = UIDocumentInteractionController(url: url)
// Configure Document Interaction Controller
self.documentInteractionController?.delegate = self
// Preview PDF
self.documentInteractionController?.presentOptionsMenu(from: self.view.frame, in: self.view, animated: true)
}


func documentInteractionControllerViewControllerForPreview(_ controller: UIDocumentInteractionController) -> UIViewController {
return self
}

我的屏幕显示如下 No pdf is being displayed here...is it because there is no app in my simulator which could open pdf files?

最佳答案

不确定是否有模拟器应用程序可以处理 pdf 文档 - 也许是新闻?但是您只需将 webView 添加到 View Controller 并使用它来查看 pdf。

@IBOutlet weak var webView: UIWebView!

对您的网址进行常规安全检查,然后:

webView.loadRequest(NSURLRequest(url: url as URL) as URLRequest)

关于ios - PDF 文件无法在 UIDocumentInteractionController 中打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42384704/

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