问题
So I'm developing an app that will need to present both PDF and PPTX files served via the HTTPS protocol. However, try as I might I can't get it to work. At first I used PDFKit, and I did the following:
URLSession.shared.dataTask(with: url!) { (data, resp, err) in
// viewer is a PDFView instance bound to the VC
self.viewer.document = PDFDocument(data: data!)
}.resume()
Nothing came up in the view. I looked down at the console and saw the following error message:
failed to find PDF header: `%PDF' not found.
I then figured PDFKit was a waste of time considering the fact that I wanted to load PowerPoint files as well so I went with QuickLook. The implementation of that just follows the documentation, simply returning a URL as a QLPreviewItem and setting the proper deletate and data source. Just as with PDFKit, it worked fine for HTTP files but not for HTTPS. Any ideas of how to circumvent this?
来源:https://stackoverflow.com/questions/51619778/cant-open-any-https-resource-swift