查看层次结构约束错误

时间:2014-08-25 15:26:07

标签: ios objective-c iphone xcode uitableview

摘要

我有一个来自Xcode Master-Detail模板的iOS项目。但是,我遇到了一个"视图层次结构没有为约束做好准备"错误。主视图中的表格单元格具有轻击手势识别器,当按下单元格时,该手势识别器会切换到详细视图。在第二次点击时,程序崩溃并出现上述错误。与代码相关的其他问题似乎是在从代码生成约束时发生的,但是我一直在使用Interface Builder,所以我还没有能够像我一样找到另一个案例。

详细视图包含UITableView和UIToolbar。是什么引起了这个?谢谢你的帮助。

Xcode输出

The view hierarchy is not prepared for the constraints: <NSLayoutConstraint:0x16d79980 V:[_UILayoutGuide:0x16d791b0]-(44)-[UITableView:0x1729b000]>
When added to a view, the constraints 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.
*** Assertion failure in -[UIView _layoutEngine_didAddLayoutConstraint:roundingAdjustment: mutallyExclusiveConstraints:]
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Impossible to set up layout with view hierarchy unprepared for constraint.'

详细控制器中tableview的约束:

详细控制器中工具栏上的约束:

1 个答案:

答案 0 :(得分:1)

我得到了这个。在检查“所有”大小类的约束时,我有一个我没有创建的顶级空间约束(或者不记得crew),而且我不想要。这是鬼影,我无法删除它。

单击“安装”复选框为所有大小的类安装此约束,禁止约束,然后我就可以删除它,解决崩溃问题。