title: How to add a subview that has its own UIViewController in Objective-C?
body: <p>I am struggling with subviews that have their own <code>UIViewControllers</code>.  I have a <code>UIViewController</code> with a view (light pink) and two buttons on a <code>toolbar</code>.  I want blue view to display when the first button is pressed and the yellow view to display with the second button is pressed.  Should be easy if I just wanted to display a view.  But the blue view will contain a table, so it needs it's own controller.  That was my first lesson.  I started off with <a href="https://stackoverflow.com/questions/23018515/how-to-add-uitableview-to-one-of-several-subviews-using-storyboard">this SO question</a> where I learned I needed a controller for the table.  </p>
  
  <p>So, I am going to back up and take some baby steps here.  Below is a picture of a simple starting point with my Utility <code>ViewController</code> (the main view controller) and the other two controllers (blue and yellow).  Imagine that when the Utility <code>ViewController</code> (the main view) is first displayed the blue (default) view will be displayed where the pink view is located.  Users will be able to click the two buttons to go back and forth and the pink view will NEVER be displayed.  I just want the blue view to go where the pink view is and the yellow view to go where the pink view is.  I hope this makes sense.</p>
  
  <p><img src="https://i.stack.imgur.com/KkKKj.png" alt="Simple Storyboard image"></p>
  
  <p>I'm trying to use <code>addChildViewController</code>. From what I have seen, there are two ways to do this: The Container View in the <code>storyboard</code> or <code>addChildViewController</code> programmatically.  I want to do it programmatically.  I don't want to use a <code>NavigationController</code> or a Tab bar.  I just want to add the controllers and shove the correct view into the pink view when the associated button is pressed.</p>
  
  <p>Below is the code I have so far.  All I want to do is display the blue view where the pink view is.  From what I have seen I should be able to just <code>addChildViewController</code> and addSubView.  This code is not doing that for me.  My confusion is getting the better of me.  Can somebody help me get the blue view displayed where the pink view is?</p>
  
  <p>This code is not intended to do anything other than display the blue view in viewDidLoad.</p>
  
  <p><strong>IDUtilityViewController.h</strong></p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  @interface IDUtilityViewController : UIViewController
  @property (strong, nonatomic) IBOutlet UIView *utilityView;
  @end
  </code></pre>
  
  <p><strong>IDUtilityViewController.m</strong></p>
  
  <pre><code>#import "IDUtilityViewController.h"
  #import "IDAboutViewController.h"
  
  @interface IDUtilityViewController ()
  @property (nonatomic, strong) IDAboutViewController *aboutVC;
  @end
  
  @implementation IDUtilityViewController
  
  - (void)viewDidLoad
  {
      [super viewDidLoad];
  
      self.aboutVC = [[IDAboutViewController alloc]initWithNibName:@"AboutVC" bundle:nil];
      [self addChildViewController:self.aboutVC];
      [self.aboutVC didMoveToParentViewController:self];
      [self.utilityView addSubview:self.aboutVC.aboutView];
  }
  
  @end
  </code></pre>
  
  <p><strong>--------------------------EDIT------------------------------</strong></p>
  
  <p>The self.aboutVC.aboutView is nil.  But I wired it up in the <code>storyboard</code>.  Do I still need to instantiate it?</p>
  
  <p><img src="https://i.stack.imgur.com/LLzhS.png" alt="enter image description here"></p>