【问题标题】:UIDocumentMenuViewController dismisses presenting view controllerUIDocumentMenuViewController 关闭呈现视图控制器
【发布时间】: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


【解决方案1】:

这是由documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentAt url: URL) 方法引起的,当您单击操作或取消UIDocumentMenuViewController 时会调用该方法。

我在这里发布了一个解决方案:https://stackoverflow.com/a/45505488/6381503

希望对你有帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-03
    • 1970-01-01
    • 2017-04-07
    • 2010-12-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多