在UIViewController中以编程方式添加UINavigationController,可以通过以下步骤实现:
import UIKit
class YourViewController: UIViewController {
// Your view controller code
}
import UIKit
class YourViewController: UIViewController {
// Your view controller code
func addNavigationController() {
let navigationController = UINavigationController(rootViewController: self)
// Customize the navigation controller if needed
}
}
import UIKit
class YourViewController: UIViewController {
// Your view controller code
func addNavigationController() {
let navigationController = UINavigationController(rootViewController: self)
// Customize the navigation controller if needed
// Add the navigation controller's view to the current view controller's view
addChild(navigationController)
view.addSubview(navigationController.view)
navigationController.didMove(toParent: self)
}
}
import UIKit
class YourViewController: UIViewController {
// Your view controller code
override func viewDidLoad() {
super.viewDidLoad()
addNavigationController()
}
func addNavigationController() {
let navigationController = UINavigationController(rootViewController: self)
// Customize the navigation controller if needed
// Add the navigation controller's view to the current view controller's view
addChild(navigationController)
view.addSubview(navigationController.view)
navigationController.didMove(toParent: self)
}
}
现在,当您运行应用程序时,您的UIViewController将以编程方式包含一个UINavigationController。
云原生正发声
T-Day
TDSQL精英挑战赛
云+社区技术沙龙[第14期]
视频云直播活动
数字化产业研学汇第三期
云+社区开发者大会(北京站)
云+社区技术沙龙[第17期]
云+社区沙龙online第6期[开源之道]
腾讯技术创作特训营第二季
云+社区沙龙online第5期[架构演进]
领取专属 10元无门槛券
手把手带您无忧上云