On My iPhone folders, how to create a folder for my app? [iOS 13]

情到浓时终转凉″ 提交于 2020-01-25 04:10:45

问题


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

Application supports iTunes file sharing and Supports opening documents in place as shown below

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

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

回答1:


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



来源:https://stackoverflow.com/questions/58125994/on-my-iphone-folders-how-to-create-a-folder-for-my-app-ios-13

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!