如何将新的子视图添加到替换根视图的容器中

时间:2014-12-17 00:30:03

标签: ios swift containers

我整合了一个滑出侧栏菜单,如Venmo或groupme或facebook。我试图建立功能来更改根视图控制器,或者根据侧栏菜单中选定的单元格将主视图更改为新的视图控制器。

我被告知要查看具有此代码的viewdidload方法。

如何在这里添加新的视图控制器?换出" centerViewController"

覆盖func viewDidLoad(){     super.viewDidLoad()

centerViewController = UIStoryboard.centerViewController()
centerViewController.delegate = self

// wrap the centerViewController in a navigation controller, so we can push views to it
// and display bar button items in the navigation bar
centerNavigationController = UINavigationController(rootViewController: centerViewController)
view.addSubview(centerNavigationController.view)
addChildViewController(centerNavigationController)

centerNavigationController.didMoveToParentViewController(self)

let panGestureRecognizer = UIPanGestureRecognizer(target: self, action: "handlePanGesture:")
centerNavigationController.view.addGestureRecognizer(panGestureRecognizer)

}

0 个答案:

没有答案