如何使用UIDocumentPickerViewController
导入SSL证书?
我正在做这样的事情:
let documentPicker: UIDocumentPickerViewController = UIDocumentPickerViewController(documentTypes: ["public.item"], in: UIDocumentPickerMode.import)
documentPicker.delegate = self
documentPicker.modalPresentationStyle = .formSheet
if #available(iOS 11.0, *) {
documentPicker.allowsMultipleSelection = false
}
UINavigationBar.appearance().tintColor = .green
self.present(documentPicker, animated: true, completion: completion)
但.cer
文件始终禁用以选择它:
此外,我找不到一种方法来导入没有扩展名的文件。
这就是我的工作方式。首先,我必须导入移动核心服务:
import MobileCoreServices
然后,这是我实例化UIDocumentPickerViewController
的方式:
let types: NSArray = NSArray(object: kUTTypeX509Certificate as NSString)
let documentPicker: UIDocumentPickerViewController = UIDocumentPickerViewController(documentTypes: types as! [String], in: UIDocumentPickerMode.import)
顺便说一句,我只使它与iCloud Drive
一起使用,它显然不适用于Google Drive
显然是由一个bug:http://www.openradar.me/24187873