ios11文件夹

File Manager

UIDocumentBrowserViewController

多了一个文件管理的 VC,默认里面会显示当前 app 权限以内的文件,包括本地的和存在 iCloud 的.

如果三方 app 在 info.plist 中声明了 UISupportsDocumentBrowser 或者 UIFileSharingEnabled 和 LSSupportsOpeningDocumentsInPlace 的话,可以获得第三方 app 的文件。

构造方法如下该构造还提供了文件筛选的能力:

 UIDocumentBrowserViewController* view = [[UIDocumentBrowserViewController alloc] initForOpeningFilesWithContentTypes:@[@".txt",@".pages",@".pdf"]];

在使用该 VC 时务必把文件管理里的 VC 作为应用的 根 VC,不要把它放在 navigation,tab 或者 split 视图中,也不要通过模态的样式展现出来。

有上述需求的话用 UIDocumentPickerViewController 来替代

由于文件可能被任何 app 中的 UIDocumentBrowserViewController 修改,所以对文件的操作尽量通过 UIDocument 子类 或者 NSFilePresenter 和 NSFileCoordinator 对象来操作。

原文地址:https://www.cnblogs.com/supersr/p/7605899.html