我有一个 VC“A”,它以模态方式呈现 VC“B”。B 提出 a协议在 B 中实现UIDocumentMenuViewController
。UIDocumentMenuDelegate
一旦documentMenuWasCancelled(_ documentMenu:)
ordocumentMenu(_:didPickDocumentPicker:)
被调用dismiss(animated:completion:)
B 被调用,我不知道为什么。
这是我的代码
func presentDocumentPicker() {
let documentTypes = [
kUTTypeCompositeContent as String,
kUTTypePDF as String,
"com.microsoft.word.doc",
"vnd.openxmlformats-officedocument.wordprocessingml.document"
]
let documentMenuViewController = UIDocumentMenuViewController(documentTypes: documentTypes, in: .import)
documentMenuViewController.delegate = self
present(documentMenuViewController, animated: true, completion: nil)
}
// MARK: - Document Menu View Controller Delegate
func documentMenu(_ documentMenu: UIDocumentMenuViewController, didPickDocumentPicker documentPicker: UIDocumentPickerViewController) {
print("did pick")
}
func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) {
print("was cancelled")
}
如您所见,我在实现的委托函数中什么都不做。仍然 B 被解雇了。我不明白。