iOS 8 Xcode 6:使用顶部/底部布局指南进行顶部/底部约束时,应用程序始终崩溃

时间:2014-09-02 22:36:41

标签: ios xcode ios8 xcode6

Xcode 6测试版最近一直在杀我。

我的故事板中有以下视图层次结构...

enter image description here

当我控制 - 从“标题视图”拖动到“视图”(反之亦然)时,我只获得“顶部/底部空间到顶部/底部布局指南”选项而不是“顶部/底部空间到容器”。当我选择附加到顶部/底部布局指南时,应用程序通常会崩溃。无论如何强制视图从superview而不是布局指南构建约束。

或者解决这个问题的最佳方法是什么?!

这是我得到的错误:

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.'

这是在让Xcode本身通过选择“重置为建议的约束”来建议约束之后。

1 个答案:

答案 0 :(得分:1)

如果这件事开始发生,我想出了如何解决这个问题。有时,当您创建约束并从Size Inspector中删除它们时(通过选择约束并按下删除按钮进行删除),约束实际上不会被删除,而是会变灰。我仍然不知道这意味着什么...为什么他们坚持,但我知道他们仍然以某种方式影响布局,这是因为他们存在应用程序崩溃。删除这些约束,一切都将按预期工作。有关如何删除灰显约束的信息,请参阅我对iOS 8 Xcode 6: What's the point of the grayed out constraints?的回答。