iOS、 swift : "Unable to simultaneously satisfy constraints" in syslog

标签 ios swift xcode crash constraints

我的第一个 iOS 应用程序被应用程序审核团队拒绝,因为它在启动时崩溃了。我无法重现这次崩溃。该应用程序在我的 iPad Mini 和所有 Xcode 模拟器上运行良好。此外,相同的构建和存档也通过了 TestFlight 内部测试。到目前为止我已经not been able to symbolicate the crash logs他们派我来的。但是,我确实在系统日志中找到了这一点:

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)]>"
)

看这个,它似乎与表格 View 、标签和按钮有关。我的应用程序基于标准的主从项目。因此,其中只有一个 TableView ,即主视图,并且该 View 中只有一个标签,位于原型(prototype)单元格中。有一次,我在原型(prototype)单元格中尝试了一个公开按钮,我怀疑上面倒数第二行的 Show More 可能是由此产生的挥之不去的影响。

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

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

根据下面康斯坦丁的建议,我尝试向标签添加约束,但唯一可用的是水平和垂直居中。其他的则呈灰色。 (参见下面的屏幕截图。)当我尝试选择水平居中时,底部的“添加约束”按钮保持灰显状态,因此我无法添加它!

enter image description here

最佳答案

那是因为宽度= 0。

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

当您错过 Show More Button 留下的 Label 的一些约束时,可能会发生这种情况

H:[UILabel:0x7fccfccc8510' ']-(NSSpace(8))-[UIButton:0x7fccfcccb710'显示更多']>

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

关于iOS、 swift : "Unable to simultaneously satisfy constraints" in syslog,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38821994/

相关文章:

ios - Apple Demo 没有 "performSelector may cause a leak because its selector is unknown"警告。有人知道为什么吗?

ios - 我们如何使用 swift 在 Collection View 上添加按钮?

ios - 找不到 Realm 文件的加密 key

ios - 如何将字符串标签(xAxis 标签)添加到图表框架中的水平条

ios - OS Sierra 10.12 上从终端重新签名 IPA 分段故障 11 错误

ios - 将日期字符串插入有序日期字符串数组中正确的索引处

ios - 无法让 S3 上传在 Xcode 10.2/Swift 中工作

ios - 归档 xcode 项目

ios - 如何在swift3中用其他元素替换数组的值?

ios - 从 Firebase 下载表格 View 中的项目过多