QuickLook不显示仅具有文件名作为标题的pdf灰色屏幕

时间:2017-09-08 12:19:34

标签: ios swift pdf quicklook

我在我的应用程序中添加了QuickLook以显示文档目录中的docs,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
                        })

1 个答案:

答案 0 :(得分:0)

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

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

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