我有一个应用程序说它MyApp是主要的wkwebview。它已经集成到文件应用程序中,因此我可以import/export从我的文件wkwebview中下载文件到本地计算机或将文件上传到服务器。
最后,我试图UIbutton在我的应用程序中构建一个允许我的用户跳转到我存储其所有内容的文件夹中的文件应用程序的应用程序。我不想在我的应用程序中构建完整的内容FileProviderUI,而是希望该按钮将用户带入文件应用程序并导航到该文件夹。
当我给出目录路径UIDocumentInteractionController并执行共享打开来呈现它时,什么也没有发生。没有错误,什么都没有。我只希望用户能够跳转到MyApp“文件”应用程序内调用的文件夹。
我以为这会很简单。添加FileProvider扩展名或FilePRoviderUI扩展名似乎多余,只是将用户跳转到此文件夹并让他与“文件”应用程序交互以执行他喜欢的任何操作 - 打开/删除/修改文档。
我必须假设用户不够精明,即使我告诉他们文件保存在文件应用程序中以便他们能够在离线时直接交互!
let documentsUrl = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
// Just jump to the folder forcing Files app to open this
let viewer = UIDocumentInteractionController(documentsUrl)
viewer.delegate = self
viewer.presentPreview(animated: true)
Run Code Online (Sandbox Code Playgroud)
没有任何内容呈现给用户,也没有任何反应。按钮点击只是悄然失败。
我想我已经明白了这一点。有一个特定的 URL 格式会自动打开文件应用程序,它是共享文档:// - 这是一个简单的功能,似乎可以简单地实现这种安静。
func openSharedFilesApp() {
let documentsUrl = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
let sharedurl = documentsUrl.absoluteString.replacingOccurrences(of: "file://", with: "shareddocuments://")
let furl:URL = URL(string: sharedurl)!
UIApplication.shared.open(furl, options: convertToUIApplicationOpenExternalURLOptionsKeyDictionary([:]), completionHandler: nil)
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1500 次 |
| 最近记录: |