Reputation: 4025
The Xcode 6 betas have been killing me lately.
I have the following view hierarchy in my storyboard...
When I control-drag from "Header View" to "View" (or vice versa) I only get "Top/Bottom Space to Top/Bottom Layout Guide" options instead of "Top/Bottom Space to Container". And when I select to attach to the top/bottom layout guide the app will usually crash. Is there anyway to force a view to build the constraint from the superview instead of the layout guides.
Or what is the best way to get around this?!
This is the error I get:
2014-09-02 15:38:07.913 BundleUp[2183:103534] The view hierarchy is not prepared for the constraint: <NSLayoutConstraint:0x7fb773fb07e0 SCHeaderView:0x7fb773fb05d0.centerX == _UILayoutGuide:0x7fb773facca0.centerX>
When added to a view, the constraint's items must be descendants of that view (or the view itself). This will crash if the constraint needs to be resolved before the view hierarchy is assembled. Break on -[UIView _viewHierarchyUnpreparedForConstraint:] to debug.
2014-09-02 15:38:07.914 BundleUp[2183:103534] *** Assertion failure in -[UIView _layoutEngine_didAddLayoutConstraint:roundingAdjustment:mutuallyExclusiveConstraints:], /SourceCache/UIKit_Sim/UIKit-3302.3.1/NSLayoutConstraint_UIKitAdditions.m:552
2014-09-02 15:38:07.917 BundleUp[2183:103534] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Impossible to set up layout with view hierarchy unprepared for constraint.'
And this was after letting Xcode itself suggest the constraints by selecting "Reset to Suggested Constraints".
Upvotes: 3
Views: 1939
Reputation: 4025
If this starts happening to you, I figured out how to solve the issue. Sometimes when you create constraints, and delete them from the Size Inspector (delete by selecting constraint and hitting the delete button), the constraint doesn't actually get deleted, but instead grays out. I still have no idea what that means... why they stick around, but I do know that they still influence the layout somehow and it's because of their existence that the app is crashing. Delete these constraints and everything will work as it should. For information on how to delete the grayed out constraints, see my answer to iOS 8 Xcode 6: What's the point of the grayed out constraints?.
Upvotes: 1