【发布时间】:2020-12-10 17:31:48
【问题描述】:
这是我调用 UIDocumentPickerViewController 来选择我的固件更新文件的代码,这些文件必须是 .zip。当我按下“选择”按钮时,会显示文档选择器视图:
@IBAction func selectButtonAction(_ sender: UIButton) {
if sender.title(for: .normal) == "Select"{
if let controller = (UIApplication.shared.delegate as? AppDelegate)?.currentViewController {
let importMenu = UIDocumentPickerViewController(documentTypes: [String(kUTTypeArchive)], in: .open )
importMenu.delegate = self
importMenu.modalPresentationStyle = .formSheet
controller.present(importMenu, animated: true, completion: nil)
}
} else {
changeDFUItemsDesign(isFileURLNil: true)
}
}
现在可以以.docx 格式打开文件,但我只需要让用户选择一种格式 - zip 文件。
我无法展示我到目前为止所做的事情,因为我无法找到解决方案。有没有办法检查 zip 文件或只是禁止选择其他格式?谢谢!
【问题讨论】:
标签: ios swift zip uidocumentpickerviewcontroller