UINavigationController方法将视图控制器添加到导航堆栈?

时间:2016-11-12 11:51:24

标签: ios swift xcode

UINavigationController的哪个方法用于在swift中将视图控制器添加到导航堆栈?

1 个答案:

答案 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)

以下是另一种可用于添加UIViewControllerUINavigationController堆栈的方法

setViewControllers(_ viewControllers: [UIViewController], animated: Bool)