I'm updating my app for iOS8 and noticed a change of behavier with [NSLayoutConstraint constraintWithItem: ..].
This works fine in iOS7, but in iOS8 having a constraint with a view that is a nested subview is not working correctly.
NSLayoutConstraint *myConstraint = [NSLayoutConstraint constraintWithItem:myView.mySubview.label attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:label2 attribute:NSLayoutAttributeBottom multiplier:1.0 constant:10.0];
Essentially, it looks like because myView.mySubview.label y coordinates are 0 within it's immediate superview (mySubview), it places label2 with respect to y=0. However the top most parent view (myView) has an arbitrary y coordinate that the constraint is not respecting. It's as if Autolayout is just taking the y coordinate of the view within its immediate superview and not in context of everything. Again this same line works fine in iOS7.
If I apply the constraint to just top level views:
NSLayoutConstraint *myConstraint = [NSLayoutConstraint constraintWithItem:label1 attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:label2 attribute:NSLayoutAttributeBottommultiplier:1.0 constant:10.0];
This works fine on iOS7 and 8.
New behavior or iOS8 bug?