1

我正在尝试将 UIDocumentPickerViewController 推送到 UINavigationController 的堆栈上但是,这会导致看起来像两个导航栏。顶部栏是导航控制器的普通导航栏。下方是包含文档选择器的取消和完成按钮的栏。单击“取消”或“完成”按钮将关闭整个视图。

问题:如何正确地将 UIDocumentPickerViewController 包含到导航控制器的堆栈中,以便取消和完成按钮出现在导航栏中,并导致上一个和下一个视图控制器出现?

4

1 回答 1

2

我相信您应该展示 UIDocumentPickerViewController 控制器而不是将其推入堆栈?我相信它应该被展示,因为它带有自己的工具栏。

是否有需要推送的特定原因?

func presentPicker() {

    var documentPicker: UIDocumentPickerViewController = UIDocumentPickerViewController(documentTypes: ["public.text"], inMode: UIDocumentPickerMode.Import)
    documentPicker.delegate = self
    documentPicker.modalPresentationStyle = UIModalPresentationStyle.FullScreen
    self.presentViewController(documentPicker, animated: true, completion: nil)

}

extension viewController: UIDocumentPickerDelegate {
    func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
        // handle picked Document
    }

    func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) {
        // pop view controller
    }

    func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentAt url: URL) {
        // handle picked Document
    }
}
于 2019-11-12T16:00:19.713 回答