ios - QuickLook 不显示仅以文件名作为标题的 pdf 灰色屏幕

标签 ios swift pdf quicklook

我在我的应用程序中添加了 QuickLook 以显示文档目录中的文档、pdf 等,它在模拟器中工作正常但在 iPad 中它只显示文件名作为标题和灰色屏幕而不是 pdf 页面,不知道出了什么问题这里有代码

docUrlLocal = jobDocument.docFileLocal
docUrlLocal = docUrlLocal.replacingOccurrences(of: "file://", with: "") 
/* Simulator path /Users/varunnaharia/Library/Developer/CoreSimulator/Devices/86CE9E4C-7D50-4831-934C-442A7558024C/data/Containers/Data/Application/86E66141-4F69-4347-81B5-415F805884C1/Documents/33fe5731-129a-4b8e-aa67-c3e840a69677.pdf 
   iPad Path     /var/mobile/Containers/Data/Application/743CEA41-89F4-4EEF-84E5-FCECA1FCB038/Documents/33fe5731-129a-4b8e-aa67-c3e840a69677.pdf
*/
let ql = QLPreviewController()
ql.dataSource  = self
parentVC.present(ql, animated: true, completion: nil)

以及下载和保存文档的代码

let fileName = (self.docURL as NSString).lastPathComponent
                    let fullFilePath = URL(fileURLWithPath: 
FileManager.documentsDir()).appendingPathComponent("\(fileName)")
                    let destination = 
DownloadRequest.suggestedDownloadDestination(for: .documentDirectory)
                    Alamofire.download(
                        self.docURL,
                        method: .get,
                        parameters: nil,
                        encoding: JSONEncoding.default,
                        headers: nil,
                        to: destination).downloadProgress(closure: { (progress) in
                            //progress closure

                        }).response(completionHandler: { (DefaultDownloadResponse) in
                            //here you able to access the DefaultDownloadResponse
                            //result closure
                            self.jobDocument.docFileLocal = fullFilePath.absoluteString
                            self.parentVC.tblView.reloadData()
                            self.btnOpen.isHidden = true
                        })

最佳答案

Idk,如果那真的是你的问题,我是这样解决的:

    let filename          = name.fileName().replacingOccurrences(of: ".", with: " ")
    let fileExtension     = name.fileExtension()
    let fixedFileTypeName = filename + fileExtension

所以问题出在文件名 (url) 中的点

关于ios - QuickLook 不显示仅以文件名作为标题的 pdf 灰色屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46116413/

相关文章:

ios - 如何将 SuperClass 对象转换为 SubClass [objective -c]

ios - 类型 'UIViewController' 的值没有成员 'addSubview' Swift2

python - 解析 PDF 文档中的表格

java - 将 SignedHash 插入 PDF 中以进行外部签名过程 -workingSample

IOS 10/plist/LSApplicationQueriesSchemes

ios - 如何在快速按下按钮时添加一个独立的 UIView?

ios - UITableView 有单元格,但不显示单元格

ios - 在调试器中出现错误 : This app has attempted to access privacy-sensitive data without a usage description

swift - SceneKit – 为什么 SCNLight 在 SCNScene 中自动创建?

python - 如何从pdf文件中提取所有链接?