ios - 与文件应用程序共享应用程序文档中的特定目录
问题描述
我创建了一个带有文件管理器的 iOS 应用程序,可以在 Documents 的子文件夹中浏览。应用程序文档中的文件夹是:
- 设置
- 根
- 温度
- 垃圾
该应用程序的文件管理器仅在“根”文件夹内浏览。其他文件夹必须对用户隐藏且不可访问。
我想与 iOS 自带的 Files App 共享“Root”文件夹,所以我在 info.plist 中添加了以下键:
<key>UIFileSharingEnabled</key>
<true/>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
它有效,但所有文件夹都暴露了,我只想暴露“根”文件夹。
是否可以在“文件”应用中共享特定文件夹?
非常感谢。
解决方案
在使用 iOS 文件系统之前,请检查 iOS 文件系统不同目录的使用情况。
根据上面的链接,苹果已经明确提到:
对于文档目录:它清楚地表明this directory should only contain files that you may wish to expose to the user.
如果你想要一些不应该暴露给用户的东西,那么不要使用Documents
目录,而是使用Library
目录。
对于Library
目录:Use the Library subdirectories for any files you don’t want exposed to the user. Your app should not use these directories for user data files.
在这里,请参阅上面链接中的以下屏幕截图,其中说明何时使用哪个目录?
简而言之,将根目录的内容保留在 Document 目录中,并将所有其他目录及其内容移至 Library 目录或 Library/Application Support 目录。因此,您的预期目的将得到实现。
推荐阅读
- machine-learning - 什么最适合这个模型?
- r - 安排_ggsurvplots 中的常见图例
- date - 脚本日期格式
- python - 正则表达式在一行中以大写单词开头和结尾,在大写单行单词中间有几行
- c++ - 临时对象在 C++ 中的行为如何?
- react-native - 当用户单击 react-native-paper 中的屏幕时如何关闭 Snackbar
- laravel - 如何更改 URL 的结构
- javascript - 我正在将 ajax 请求传递给其他远程服务器以获取访问记录
- sql - 比较列的先前版本
- python - 如何使用 python 从音频 wav 文件中获取 rms?