title: Add a child view controller's view to a subview of the parent view controller
body: <p>I want to add a tableViewController as a child view controller of a containerViewController (shown below). According to Apple's <a href="http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/CreatingCustomContainerViewControllers/CreatingCustomContainerViewControllers.html" rel="noreferrer">View Controller Programming Guide</a> I can achieve this by the following lines of code inside my containerViewController:</p>
  
  <pre><code>   [self addChildViewController:tableViewController];
     [self.view addSubview:tableViewController.view];
     [tableViewController didMoveToParentViewController:self];
  </code></pre>
  
  <p>In fact, that works fine. Now the problem is that I do not want to add the tableViewController's view as a subview of the containerViewController's root view. Instead I want to add it as a subview of the containerView (see image) which itself is a subview of the containerViewController's root view. So I changed the above code as follows:</p>
  
  <pre><code>   [self addChildViewController:tableViewController];
     [self.contentView addSubview:tableViewController.view];
     [tableViewController didMoveToParentViewController:self];
  </code></pre>
  
  <p>Now when I launch the app it crashes immediately with this error:</p>
  
  <blockquote>
    <p>Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency', reason: 'child view controller: should have parent view controller: but actual parent is:'</p>
  </blockquote>
  
  <p>What is the problem here? Is it not possible to add a childViewController's view to a specific <strong><em>sub</em></strong> view of its containerViewController? Or how can I achieve this without an error in the view controller hierarchy?</p>
  
  <p><img src="https://i.stack.imgur.com/sllxQ.png" alt="containerViewController"></p>