【问题标题】:How to embed a view controller into a navigation view controller programmatically如何以编程方式将视图控制器嵌入到导航视图控制器中
【发布时间】:2019-07-24 23:08:18
【问题描述】:

我正在尝试将我的视图控制器嵌入到导航视图控制器中,以便获得导航栏和所有其他东西,如后退按钮。我想以编程方式进行。

【问题讨论】:

  • 到目前为止您尝试过什么?你有什么问题?

标签: swift uiviewcontroller uinavigationcontroller


【解决方案1】:

这样做是这样的:

// example ViewController
let myVC = UIViewController()

// create the NavigationController with my VC as root
let navCon = UINavigationController(rootViewController: myVC)

【讨论】:

  • 那会给导航栏吗
  • 是的。对于标题,设置 myVC.title = “title text”。当你按下下一个 VC 时,你会得到一个返回按钮。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-20
  • 2021-02-03
  • 1970-01-01
  • 1970-01-01
  • 2017-06-16
  • 1970-01-01
相关资源
最近更新 更多