简体   繁体   English

在我的 iPhone 文件夹上,如何为我的应用创建文件夹? [iOS 13]

[英]On My iPhone folders, how to create a folder for my app? [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我正在尝试在文件应用程序中为我的应用程序创建一个文件夹,以便在我想从我的应用程序中保存文件时进行访问

In iOS 12 and earlier i could achieve this by enabling在 iOS 12 及更早的版本中,我可以通过启用

Application supports iTunes file sharing and Supports opening documents in place as shown below Application supports iTunes file sharingSupports opening documents in place如下图所示

在此处输入图像描述

Since updating to iOS 13, the same folder that used to show up in iOS 12 no-longer shows.自从更新到 iOS 13 后,以前出现在 iOS 12 中的同一文件夹不再显示。

What has changed and how can i get this resolved in iOS 13?发生了什么变化,我怎样才能在 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,对于那些寻找上述特定问题的答案的人,

Updating to iOS 13.1 seems to fix this issue, so i'm not sure if this was a bug of some sort更新到 iOS 13.1 似乎可以解决这个问题,所以我不确定这是否是某种错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在我的 iPhone / 在我的 iPad 文件夹上,如何为我的应用程序创建一个文件夹? - On My iPhone / On My iPad folders, how to create a folder for my app? 如何在我的自定义目录中创建文件夹并提前在 /myapp/documents 中创建一个文件夹(当我构建应用程序时)? - How can I make folders in my custom directory and create create a folder in /myapp/documents in advance(when I build the app)? 如何使用Beta iOS在iPhone上运行我的应用程序? - How do I run my app on my iPhone with the Beta iOS? 我的iPhone应用程序因ios 7而崩溃 - My iphone app crashes for ios 7 如何 Flutter 将文件写入 iOS iPhone“在我的手机上查找”文件夹 - How to Flutter write files to iOS iPhone “Find on my phone” Folder iOS Swift,“在我的iPhone上”文件夹的网址是什么 - iOS Swift, what is the url of the “on my iPhone” folder 如何允许 IOS 13 上的浏览​​器访问我的 iPhone 6s 陀螺仪? - How do I allow a browser on IOS 13 to access my iPhone 6s' Gyroscope? 如何为我的iOS应用创建证书 - How to create a certificate for my iOS App 如何为我的iOS应用程序创建小部件? - How to create widget for my iOS app? 如何从iPhone的应用程序文档文件夹中将图像保存到设备图像库文件夹中? - How to save image in my device image library folder from my app document folder in iPhone?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM