UIDocumentPickerViewController导入SSL证书

时间:2017-12-16 00:28:25

标签: ios swift uidocumentpickervc

如何使用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文件总是禁用以选择它:

cer disabled

另外,我找不到一种方法来导入没有扩展名的文件。

1 个答案:

答案 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