title: Error using activateConstraints on a collection of Container View constraints
body: <p>In my iOS 8 app using size classes, to get the iPad to have a different layout in portrait and landscape I have an <code>IBOutletCollection</code> for each orientation that I activate and deactivate.  This has worked great up until the introduction of a Container View.</p>
  
  <p>I'm adding a new VC that is a separate tab item in the iPhone version, but I embed it into the iPad layout using a Container View.  I'll focus on just one size class, RegularRegular.  The container view has 4 constraints: Trailing, Leading, Top, and Bottom.  When I run the app, it looks fine (in that single orientation).</p>
  
  <p>Now, when I add these 4 constraints to my <code>IBOutletCollection</code>, the <code>activateConstraints</code> message fails with the following error message:</p>
  
  <p>*** Terminating app due to uncaught exception 'NSGenericException', reason: 'Unable to activate constraint with items ; layer = ; contentOffset: {0, 0}; contentSize: {460, 78}> and > because they have no common ancestor.  Does the constraint reference items in different view hierarchies?  That's illegal.'</p>
  
  <p>The constraints don't reference items in different view hierarchies.  Top, Bottom, and Leading are all in relation to another view that is also in the VC's view.  The Trailing is in relation to a stepper that is also in the VC's view.  So they're all at the same hierarchal level to my knowledge.  </p>
  
  <p>When in debug, I can see that the constraint starts off with its <code>active</code> property as <code>nil</code>.  This appears to be normal (the non-container constraints started off the same prior to them being set to <code>YES</code>).  I checked this with a for loop setting the <code>active</code> property.</p>
  
  <p>Is there something I'm doing wrong with the constraints on the Container View?  Are constraints on a Container View somehow special because they are on a Container View?  I've tried finding the answer myself, but I can't seem to find anything in regard to this issue I'm having.  </p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p><em>4/10 Edit to provide pictures &amp; code.  Note at this time I've broken out the container constraints into a separate array so I can deal with them on their own.</em>  </p>
  
  <p>In the image below, the container's Leading, Top, and Bottom constraints are in relation to the view to the right of the container.  The Trailing constraint is in relation to the stepper above it.
  <img src="https://i.stack.imgur.com/5xqts.png" alt="VC Layout"></p>
  
  <p>Related code:</p>
  
  <pre><code>@property (strong, nonatomic) IBOutletCollection(NSLayoutConstraint) NSArray *regularAnyConstraints;
  @property (strong, nonatomic) IBOutletCollection(NSLayoutConstraint) NSArray *regularAnyContainerConstraints;
  
  @property (strong, nonatomic) IBOutletCollection(NSLayoutConstraint) NSArray *anyRegularConstraints;
  @property (strong, nonatomic) IBOutletCollection(NSLayoutConstraint) NSArray *anyRegularContainerConstraints;
  </code></pre>
  
  <p>These are the constraints in the <code>_anyRegularContainerConstraints</code> array:
  <img src="https://i.stack.imgur.com/Oc9uy.png" alt="_anyRegularContainerConstraints"></p>
  
  <pre><code>[NSLayoutConstraint deactivateConstraints:_regularAnyConstraints];
  [NSLayoutConstraint activateConstraints:_anyRegularConstraints];
  
  [NSLayoutConstraint deactivateConstraints:_anyRegularContainerConstraints];
  [NSLayoutConstraint activateConstraints:_anyRegularContainerConstraints];
  </code></pre>