嗨,cesare,问题可以通过在基类中获取containerView解决,您可以在其中取三个不同的viewControllers。
请查找这些简单的教程,您可以通过编程方式添加或删除子viewController。
private func add(asChildViewController viewController: UIViewController) {
// Add Child View Controller
addChildViewController(viewController)
// Add Child View as Subview
view.addSubview(viewController.view)
// Configure Child View
viewController.view.frame = view.bounds
viewController.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
// Notify Child View Controller
viewController.didMove(toParentViewController: self)
}
private func remove(asChildViewController viewController: UIViewController) {
// Notify Child View Controller
viewController.willMove(toParentViewController: nil)
// Remove Child View From Superview
viewController.view.removeFromSuperview()
// Notify Child View Controller
viewController.removeFromParentViewController()
}
以下是参考链接:
tabBarController.selectedIndex = yourIndex
决定要显示哪个选项卡。