我的应用程序暂时停留在iOS 13上,我无法获得UIDocumentPickerViewController,只允许选择二进制文件。
这就是我在我的信息列表中输入的内容
<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的文件?
.bin标记已经由com.apple.macbinary-archive声明,因此要做到这一点,您应该避免重新声明自己的类型,而直接使用苹果提供的类型。