UINavigationController的哪个方法用于在swift中将视图控制器添加到导航堆栈?
答案 0 :(得分:2)
通常情况下,使用以下方法将UIViewController
推送到UINavigationController
的导航堆栈
pushViewController(_ viewController: UIViewController, animated: Bool)
这是通过以下方式在CustomViewController
课程中实现的:
let someVC: CustomViewController = CustomViewController() // this is one way of initializing it
self.navigationController?.pushViewController(someVC, animated: true)
以下是另一种可用于添加UIViewController
到UINavigationController
堆栈的方法
setViewControllers(_ viewControllers: [UIViewController], animated: Bool)