iOS,Swift:"无法同时满足约束条件"在syslog中

时间:2016-08-08 05:43:48

标签: ios swift xcode crash constraints

我的第一个iOS应用程序被App Review团队拒绝,因为它在发布时崩溃了。我无法重现这次崩溃。该应用程序在我的物理iPad Mini和所有Xcode模拟器上运行良好。此外,相同的构建和存档通过TestFlight内部测试传递。我到目前为止not been able to symbolicate the crash logs他们已经寄给我了。但是,我确实在syslog中找到了这个:

Aug  7 17:04:44 Michaels-MacBook-Pro-3 SpringBoard[1333]: Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. 
    Try this: 
        (1) look at each constraint and try to figure out which you don't expect; 
        (2) find the code that added the unwanted constraint or constraints and fix it. 
(
    "<NSLayoutConstraint:0x7fccfccd0300 UILabel:0x7fccfccc8510' '.leading == SPUISearchTableHeaderView:0x7fccfccc59f0.leadingMargin>",
    "<NSLayoutConstraint:0x7fccfccd0f80 H:[UILabel:0x7fccfccc8510' ']-(NSSpace(8))-[UIButton:0x7fccfcccb710'Show More']>",
    "<NSLayoutConstraint:0x7fccfccd0fd0 SPUISearchTableHeaderView:0x7fccfccc59f0.trailingMargin == UIButton:0x7fccfcccb710'Show More'.trailing>",
    "<NSLayoutConstraint:0x7fccfccc8880 'UIView-Encapsulated-Layout-Width' H:[SPUISearchTableHeaderView:0x7fccfccc59f0(0)]>"
)

看着这个,它似乎与表格视图,标签和按钮有关。我的应用程序基于标准的Master-Detail项目。因此,其中只有一个表视图,即主视图,该视图中只有一个标签,位于原型单元格中。有一次,我在原型单元格中尝试了一个公开按钮,我怀疑上面第二行到第二行的Show More可能是一种挥之不去的效果。

SPUISearchTableHeaderView上搜索我在github中找到了this。我注意到它确实增加了一些约束。这些约束实际上包含文本moreButton

所以我觉得我可能正在探究崩溃的原因:我认为它有一些限制因素是以编程方式添加的,可能会遗留在我的披露按钮实验中。但我完全不确定如何从这里开始。标签上没有明确的限制(见下面的屏幕截图),我认为没有。任何帮助将不胜感激! screen shot showing label

根据Konstantin的建议,我尝试在标签上添加约束,但唯一可用的是水平和垂直居中。其他人都是灰色的。 (见下面的截图。)当我尝试选择水平居中时,底部的“添加约束”按钮仍然显示为灰色,因此我无法添加它!

enter image description here

1 个答案:

答案 0 :(得分:0)

那是因为你有宽度= 0。

UIView-Encapsulated-Layout-Width' H:[SPUISearchTableHeaderView:0x7fccfccc59f0(0)]

当您错过Label的某些约束时可能会发生这种情况,该约束来自Show More Button

H:[UILabel:0x7fccfccc8510' ']-(NSSpace(8))-[UIButton:0x7fccfcccb710'Show More']>

验证这些标签是否具有前导约束。