![](/img/trans.png)
[英]iOS 13 How to use UIDocumentPickerViewController with App Group?
[英]Getting UIDocumentPickerViewController to only allow the selection of binary data files on iOS 13
我的應用程序暫時停留在 iOS 13,我無法獲取 UIDocumentPickerViewController 僅允許選擇二進制文件。
這就是我要放入 info.plist 的內容
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeIdentifier</key>
<string>public.firmware</string>
<key>UTTypeDescription</key>
<string>Firmware Binary</string>
<key>UTTypeIconFile</key>
<string></string>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeIconFiles</key>
<array/>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>bin</string>
</array>
<key>public.mime-type</key>
<string>application/octet-stream</string>
</dict>
</dict>
</array>
這是我在選擇時連接到按鈕的內容
let vc = UIDocumentPickerViewController(documentTypes: ["public.firmware"], in: .import)
vc.delegate = self
self.present(vc, animated: true)
我會使用 UTType,但它在 iOS 13 中不可用。另外,我不確定我是否使用了正確的 mime 類型。 我從這個列表中選擇了八位字節流https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
你的目標到底是什么? 允許選擇文件擴展名為 .bin 的文件嗎?
com.apple.macbinary-archive 已經聲明了 .bin 標記,因此您應該避免重新聲明自己的類型,而直接使用 Apple 提供的類型。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.