在“我的iPhone"文件夹中,如何为我的应用程序创建文件夹?[iOS 13] [英] On My iPhone folders, how to create a folder for my app? [iOS 13]

查看:82
本文介绍了在“我的iPhone"文件夹中,如何为我的应用程序创建文件夹?[iOS 13]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在文件"应用中为我的应用创建一个文件夹,以便在我要从应用中保存文件时进行访问

I am trying to create a folder for my app in the Files app for access when i want to save a file from my app

在iOS 12及更低版本中,我可以通过启用

In iOS 12 and earlier i could achieve this by enabling

应用程序支持iTunes文件共享,并且支持就地打开文档,如下所示

自从更新到iOS 13之后,不再显示与iOS 12中不再显示的文件夹相同的文件夹.

Since updating to iOS 13, the same folder that used to show up in iOS 12 no-longer shows.

发生了什么变化,如何在iOS 13中解决此问题?

What has changed and how can i get this resolved in iOS 13?

我使用以下扩展名保存文件:

I use the extension below to save files:

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)")
        }
    }
}

推荐答案

对于那些正在寻找上述特定问题的答案的人,

For those looking for the answer to the specific problem above,

更新到iOS 13.1似乎可以解决此问题,所以我不确定这是否是某种错误

Updating to iOS 13.1 seems to fix this issue, so i'm not sure if this was a bug of some sort

这篇关于在“我的iPhone"文件夹中,如何为我的应用程序创建文件夹?[iOS 13]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆