我知道有人問過類似的問題,但我找不到任何可以解決我問題的東西。
就我而言,我開發了一個 iOS 應用程式(Xcode 13.4)來匯入和決議我使用 .csv 檔案選擇的 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/>
但沒有任何效果。我錯過了什么嗎?提前致謝!
uj5u.com熱心網友回復:
如果有人感興趣,我可以通過在實際訪問檔案之前在檔案選擇器中呼叫 url.startAccessingSecurityScopedResource() 來解決它。希望這可以幫助!
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/479372.html
