iOS 14 中的问题 UIDocumentPickerViewController

Problem UIDocumentPickerViewController in iOS 14

抱歉提出这个问题,但我找不到解决方案或者我无法理解... 直到现在我一直在使用这个函数。

func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
        
        
         // Importo
         if controller.documentPickerMode == .import {
          
         my code
         }

       // Esporto
         if controller.documentPickerMode == .exportToService {
          may code
         }

现在,ios 14 中的 .documentPickerMode 不再存在,我怎样才能得到相同的结果?或者他会知道我是进口还是出口?

TKS

现在你必须使用四种不同的方法。两个用于导出,另外两个用于打开您指定的文档类型:


Creates and returns a document picker that can export the types of documents you specify.

init(forExporting: [URL])

Creates and returns a document picker that can export or copy the types of documents you specify.

init(forExporting: [URL], asCopy: Bool)

Creates and returns a document picker that can open the types of documents you specify.

init(forOpeningContentTypes: [UTType])

Creates and returns a document picker that can open or copy the types of documents you specify.

init(forOpeningContentTypes: [UTType], asCopy: Bool)

然后当它被调用时你切换控制器:

func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {

    switch controller {
        case documentExporter:
            print("documentExporter")
        case documentImporter:
            print("documentImporter")
        default: break
    }

}