One way to instantiate ViewControllers is to do it all programmatically like this

Screen Shot 2017-01-11 at 1.37.47 PM.png

Screen Shot 2017-01-11 at 1.38.01 PM.png

But another way to do it is by embedding the ViewController directly in the parent viewController and loading it from there.

Go to you parent viewController (the one you want to have childViewControllers that you swap in and out) and add a ‘ContainerView’

Screen Shot 2017-01-11 at 1.40.52 PM.png

This will give you a new ViewController with a segue out of the parent. Delete the VC they give you. Create a new one. Create a ViewController.

Control drag from the ContainView to the new VC you just created and select embed.

Screen Shot 2017-01-11 at 1.44.20 PM.png

Bind the ViewController to that new ViewController you just dragged out, and then load it like this.

Screen Shot 2017-01-11 at 1.42.35 PM.png

Same thing as we did before. But just another way of doing it.

 

Advertisements