[英]Getting UIDocumentPickerViewController to only allow the selection of binary data files on iOS 13
My app is stuck at iOS 13 for the time being, and I can't get the UIDocumentPickerViewController only to allow the selection of binary files.我的应用程序暂时停留在 iOS 13,我无法获取 UIDocumentPickerViewController 仅允许选择二进制文件。
This is what I'm putting into my info.plist这就是我要放入 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>
Here's what I'm hooking up to a button upon selection这是我在选择时连接到按钮的内容
let vc = UIDocumentPickerViewController(documentTypes: ["public.firmware"], in: .import)
vc.delegate = self
self.present(vc, animated: true)
I'd use UTType but it's not available in iOS 13. Also, I'm not sure if I'm using the correct mime-type.我会使用 UTType,但它在 iOS 13 中不可用。另外,我不确定我是否使用了正确的 mime 类型。 I chose octet-stream from this list https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types我从这个列表中选择了八位字节流https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
What is your goal exactly?你的目标到底是什么? Allow selecting files with the file extension .bin?允许选择文件扩展名为 .bin 的文件吗?
The .bin tag is already claimed by com.apple.macbinary-archive, so to do that you should avoid redeclaring your own type and just use that Apple-provided type directly. com.apple.macbinary-archive 已经声明了 .bin 标记,因此您应该避免重新声明自己的类型,而直接使用 Apple 提供的类型。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.