代码之家  ›  专栏  ›  技术社区  ›  PvDev

如何在iOS Swift中从google驱动器加载pdf url?

  •  1
  • PvDev  · 技术社区  · 6 年前

    我正在尝试使用 懒散的文件 . 安装 对于注释、修改等,现在我可以从本地[从xcode项目内部]加载pdf,编辑并保存。这是我目前尝试的代码:

     let pdfs = Bundle.main.paths(forResourcesOfType: "pdf", inDirectory: nil)
    
        let data = try? Data(contentsOf: URL(fileURLWithPath: pdfs.first!))
    
        let filePath = pdfs.first
    
        let document = LazyPDFDocument(filePath: filePath, password: phrase)
    
        if document != nil {
    
            let lazyPDFViewController = LazyPDFViewController(lazyPDFDocument: document)
    
            lazyPDFViewController?.delegate = self
    
            let file = FileManager.default.createFile(atPath: (document?.filePath)!, contents: data, attributes: nil)
    
            lazyPDFViewController?.modalTransitionStyle = .crossDissolve
    
            lazyPDFViewController?.modalPresentationStyle = .fullScreen
    
            self.present(lazyPDFViewController!, animated: true, completion: nil)
    
        }
    

    我的问题是从 谷歌硬盘 使用 懒散的驾驶员 ?

    非常感谢您的帮助。。。

    0 回复  |  直到 6 年前