我正在尝试将UIDocumentPickerViewController推入UINavigationController的堆栈中。但是,这导致看起来像两个导航栏。顶部栏是导航控制器的常规导航栏。在下面的栏包含文档选择器的“取消”和“完成”按钮。单击取消或完成按钮可关闭整个视图。
问题:如何正确地将UIDocumentPickerViewController包含在导航控制器的堆栈中,以使“取消”和“完成”按钮出现在导航栏中,并使上一个和下一个视图控制器出现?
最佳答案
我相信您应该展示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
}
}
关于ios - 如何将UIDocumentPickerViewController与UINavigationController一起使用?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/58821493/