[英]Present UINavigationController from UITabBarController tab root view
I'd like to present a navigation controller from a tab bar controller's tab's root view controller and have the tabs from the tab bar controller visible. 我想从标签栏控制器的选项卡的根视图控制器中显示导航控制器,并使标签栏控制器中的选项卡可见。
Here's a photo of an example storyboard: 这是一个示例故事板的照片:
The tab bar controller has a relationship to the ItemOneViewController
, which is implemented like this: 标签栏控制器与
ItemOneViewController
有关系,它实现如下:
import UIKit
class ItemOneViewController: UIViewController {
private func presentNavigationController() {
let id = "NavController"
guard let vc = storyboard?.instantiateViewController(withIdentifier: id) else { return }
present(vc, animated: true)
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
presentNavigationController()
}
}
I hoped that by presenting the navigation controller from the root view controller of a tab on a tab bar controller that the navigation controller would be presented behind the tabs, but when I run the described app, this is what the simulator looks like: 我希望通过从标签栏控制器上的选项卡的根视图控制器呈现导航控制器,导航控制器将显示在选项卡后面,但是当我运行所描述的应用程序时,这就是模拟器的样子:
This is what the view hierarchy looks like: 这是视图层次结构的样子:
I think I remember a previous colleague mentioning that a UINavigationController
will replace the view stack, which makes sense but is there anyway to keep it or bring the UITabBarController
with it? 我想我记得前一位同事提到
UINavigationController
将替换视图堆栈,这是有道理的,但无论如何要保留它或带UITabBarController
吗?
I've tried adjusting the presentation style and context but haven't had any luck. 我试过调整演示风格和背景但没有运气。
尝试在导航控制器中嵌入ItemOneViewController,而不是在导航控制器中嵌入ViewController VC。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.