我想从选项卡栏 Controller 的选项卡 Root View Controller 中呈现一个导航 Controller ,并使选项卡栏 Controller 中的选项卡可见。
标签栏 Controller 与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()
}
}
我希望通过从选项卡栏 Controller 上的选项卡的 Root View Controller 显示导航 Controller ,导航 Controller 将显示在选项卡后面,但是当我运行所描述的应用程序时,这就是模拟器的样子:
这就是 View 层次结构的样子:
我想我记得以前的一位同事提到 UINavigationController
将取代 View 堆栈,这是有道理的,但无论如何都要保留它或带上 UITabBarController
?
我尝试过调整演示风格和上下文,但没有成功。
最佳答案
尝试将 ItemOneViewController 嵌入到导航 Controller 中,而不是将 ViewController VC 嵌入到导航 Controller 中。
关于ios - 从 UITabBarController 选项卡 Root View 呈现 UINavigationController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55466913/