在 iOS 中导入文件:UIDocumentPicker 与 UIDocumentBrowser

Importing files in iOS : UIDocumentPicker vs UIDocumentBrowser

根据文档,UIDocumentPickerViewController and UIDocumentBrowserViewController 都可用于在应用程序沙箱外导入文档。

对于从本地文档 providers/cloud 位置选择和导入文档,以上哪个位置最好 suited.Can 我仍然在 iOS 11 中使用 UIDocumentPickerViewController?

根据以下文档 Apple documentation for document picker ,在您的应用程序可以使用文档选择器之前,您必须在 Xcode 中打开 iCloud 文档功能并且 iCloud 容器应该映射到 appId.Is 如果我只做导入操作,这是强制性的吗?我已经尝试使用 UIDocumentPickerViewController,即使没有上述权利,它似乎也能正确返回选定的文件路径。

如果您不需要自己的 iCloud 容器,则不需要授权。如果您只想导入文件,可以使用 UIDocumentPickerViewController 而无需添加授权。

是的,UIDocumentPickerViewController 适用于 iOS 11.

UIDocumentBrowserViewController 必须是您应用程序的根视图,因此根据我的经验,您不能在现有应用程序中使用并成为 NavigationControl 的一部分(您将无法正确获取后退按钮)。在这些情况下,我们需要使用 UIDocumentPickerViewController。希望这有帮助。