Skip to content

Instantly share code, notes, and snippets.

@ivangodfather
Created July 7, 2015 18:20
Show Gist options
  • Select an option

  • Save ivangodfather/9b49b6dc1ebf8a5e49e7 to your computer and use it in GitHub Desktop.

Select an option

Save ivangodfather/9b49b6dc1ebf8a5e49e7 to your computer and use it in GitHub Desktop.
var childVC: UIViewController?
@IBOutlet weak var containerView: UIView!
func ChangeViewController() {
childVC?.willMoveToParentViewController(nil)
childVC?.view.removeFromSuperview()
childVC?.removeFromParentViewController()
childVC = storyboard?.instantiateViewControllerWithIdentifier("identifier") as? UIViewController
if let childVC = childVC {
addChildViewController(childVC)
childVC.view.frame = containerView.bounds
containerView.addSubview(childVC.view)
childVC.didMoveToParentViewController(self)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment