我知道有人问过类似的问题,但我找不到任何可以解决我的问题的东西。
就我而言,我开发了一个 iOS 应用程序 (Xcode 13.4),用于从我使用选择的 CSV 文件导入和解析数据UIDocumentPickerViewController
。在模拟器上一切正常,但是当我在 iPhone 上运行该应用程序时,当我选择一个文件并尝试解析它时,我的应用程序崩溃并出现错误The file "test.csv" couldn’t be opened because you don’t have permission to view it
。我已在我的文件中添加了与文档访问相关的所有权限Info.plist
如下:
<key>NSFileProviderDomainUsageDescription</key>
<string>Description</string>
<key>UISupportsDocumentBrowser</key>
<true/>
<key>NSDesktopFolderUsageDescription</key>
<string></string>
<key>NSDownloadsFolderUsageDescription</key>
<string></string>
<key>NSFileProviderPresenceUsageDescription</key>
<string></string>
<key>NSAppleMusicUsageDescription</key>
<string></string>
<key>UIFileSharingEnabled</key>
<true/>
<key>NSDocumentsFolderUsageDescription</key>
<string>Description</string>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
但没有任何作用。我错过了什么吗?提前致谢!
如果有人感兴趣,我可以在实际访问文件之前通过在文档选择器中调用 url.startAccessingSecurityScopedResource() 来解决这个问题。希望这可以帮助!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)