ios - 从 UITabBarController 选项卡 Root View 呈现 UINavigationController

标签 ios swift uinavigationcontroller uitabbarcontroller

我想从选项卡栏 Controller 的选项卡 Root View Controller 中呈现一个导航 Controller ,并使选项卡栏 Controller 中的选项卡可见。

这是示例 Storyboard的照片: enter image description here

标签栏 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 将显示在选项卡后面,但是当我运行所描述的应用程序时,这就是模拟器的样子:

enter image description here

这就是 View 层次结构的样子:

enter image description here

我想我记得以前的一位同事提到 UINavigationController 将取代 View 堆栈,这是有道理的,但无论如何都要保留它或带上 UITabBarController

我尝试过调整演示风格和上下文,但没有成功。

最佳答案

尝试将 ItemOneViewController 嵌入到导航 Controller 中,而不是将 ViewController VC 嵌入到导航 Controller 中。

关于ios - 从 UITabBarController 选项卡 Root View 呈现 UINavigationController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55466913/

相关文章:

ios - Swift:在闭包中捕获函数参数是否会强烈保留它?

ios - 如何从 Swift 调试器访问对象嵌套属性

ios - 如何在 Xcode 中使用 for 循环声明属性

ios - 注释显示标注而不是开始拖放操作

Swift:使用常量属性定义另一个属性失败

ios - UIPickerView 选择行不起作用 ios7

ios - UINavigationBar 中的菜单

ios - 从 iOS 添加事件到 Google 日历

iOS [Obj-C] - 滚动时导航栏透明且项目可见

ios - Swift 重命名后退导航项