【发布时间】:2017-03-27 17:45:56
【问题描述】:
我有一个 VC “A”,它以模态方式呈现 VC “B”。 B 呈现UIDocumentMenuViewController
UIDocumentMenuDelegate 协议在 B 中实现。
只要documentMenuWasCancelled(_ documentMenu:) 或documentMenu(_:didPickDocumentPicker:) 被调用,B 的dismiss(animated:completion:) 就会被调用,我不知道为什么。
这是我的代码
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 被解雇了。没看懂。
【问题讨论】:
-
您可以将更多项目发送到或至少发送到您那里的完整 ViewController 吗?
-
实际上现在我无法重现它:D
-
您如何呈现两个控制器可能存在问题..
-
@lukwuerz,我在模拟器中遇到了同样的问题。只要我在 UIDocumentMenuViewController 中执行任何操作,视图 B 就会消失。您是否能够获得有关此问题的更多信息?是不是又开始出现了?是只在模拟器上还是在真机上?
标签: ios swift uiviewcontroller presentmodalviewcontroller uidocumentmenuvc