ios - 在我的 iPhone 文件夹上,如何为我的应用创建文件夹?[iOS 13]
问题描述
当我想从我的应用程序中保存文件时,我正在尝试在文件应用程序中为我的应用程序创建一个文件夹以供访问
在 iOS 12 及更早版本中,我可以通过启用
Application supports iTunes file sharing
如下Supports opening documents in place
图所示
自从更新到 iOS 13 后,过去在 iOS 12 中显示的同一文件夹不再显示。
发生了什么变化?如何在 iOS 13 中解决这个问题?
我使用下面的扩展来保存文件:
extension WebViewController: URLSessionDownloadDelegate {
func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didFinishDownloadingTo location: URL) {
// create destination URL with the original pdf name
guard let url = downloadTask.originalRequest?.url else { return }
let documentsPath = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask)[0]
let destinationURL = documentsPath.appendingPathComponent(url.lastPathComponent)
// delete original copy
try? FileManager.default.removeItem(at: destinationURL)
// copy from temp to Document
do {
try FileManager.default.copyItem(at: location, to: destinationURL)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2){
let activityViewController = UIActivityViewController(activityItems: [self.fileName, destinationURL], applicationActivities: nil)
if(UIDevice.current.userInterfaceIdiom == .pad){
if let popOver = activityViewController.popoverPresentationController {
popOver.sourceView = self.view
popOver.sourceRect = self.view.bounds
popOver.barButtonItem = self.navigationItem.rightBarButtonItem
self.present(activityViewController, animated: true, completion: nil)
}
}
else{
self.present(activityViewController, animated: true, completion: nil)
}
}
} catch let error {
print("Copy Error: \(error.localizedDescription)")
}
}
}
解决方案
对于那些寻找上述特定问题的答案的人,
更新到 iOS 13.1 似乎可以解决这个问题,所以我不确定这是否是某种错误
推荐阅读
- redux - 中间件中的调度导致错误类型的操作
- javascript - 删除事件侦听器不起作用
- python - (垂直)滚动视图包含另一个(水平)滚动视图 - Kivy
- vue.js - Vue JS 如何从一个数据中取一个值到另一个数据?
- javascript - ShellExecute 权限被拒绝 SCRIPT70,IE11 windows 10
- go - 如何对模板中的结构切片中包含的切片进行范围划分?
- google-cloud-platform - GCP - 如何为虚拟机部署添加标签
- runtime - GPRbuild:聚合项目中忽略的“运行时”属性
- angular - Angular 7 - 提取外部主机名并使用它来创建图像的名称
- python-3.x - Pandas pivot_table:定义列