如何使用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
文件总是禁用以选择它:
另外,我找不到一种方法来导入没有扩展名的文件。
答案 0 :(得分:0)
这就是我的工作方式。首先,我必须导入移动核心服务:
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
一起使用http://www.openradar.me/24187873