简体   繁体   English

iOS,Swift:系统日志中“无法同时满足约束条件”

[英]iOS, Swift: “Unable to simultaneously satisfy constraints” in syslog

My first iOS app got rejected by the App Review team because it crashed on launch. 我的第一个iOS应用程序因启动时崩溃而被App Review团队拒绝。 I can't reproduce this crash. 我无法重现此崩溃。 The app runs fine on my physical iPad Mini and on all the Xcode simulators. 该应用程序可以在我的物理iPad Mini和所有Xcode模拟器上正常运行。 Also, the same build and archive was passed through TestFlight Internal Testing. 另外,相同的构建和存档也通过了TestFlight内部测试。 I have so far not been able to symbolicate the crash logs they sent me. 到目前为止,我还无法表示他们发送给我的崩溃日志 However, I did find this in the 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)]>"
)

Looking at this, it seems to pertain to a table view, a label and a button. 看来,这似乎与表格视图,标签和按钮有关。 My app is based on the standard Master-Detail project. 我的应用程序基于标准的Master-Detail项目。 So there is only one table view in it, the master, and there is only one label in that view, which is in the prototype cell. 因此,其中只有一个表视图,即主视图,并且在该视图中,只有一个标签位于原型单元中。 At one point, I experimented with a disclosure button in the prototype cell, and I suspect the Show More on the second to the last line above may be a lingering effect from that. 有一次,我在原型单元中尝试了一个“显示”按钮,我怀疑上面第二到最后一行的“ Show More ”可能会产生挥之不去的效果。

Searching on SPUISearchTableHeaderView I found this in github. SPUISearchTableHeaderView搜索,我在github中找到了这个 I notice that it does add a couple of constraints. 我注意到它确实增加了一些约束。 And those constraints actually contain the text moreButton . 这些约束实际上包含文本moreButton

So I feel like I may be on the trail of the cause of the crash: I'm thinking it's some constraints being added programmatically, possibly left over from my experiment with the disclosure button. 因此,我感觉自己可能正处于崩溃原因的轨道上:我认为这是以编程方式添加的一些约束,可能是我在实验中使用披露按钮遗留下来的约束。 But I'm not at all sure how to proceed from here. 但是我完全不确定如何从这里开始。 There are no explicit constraints on the label (see screen shot below), and I don't think there ever were. 标签上没有明确的限制(请参见下面的屏幕截图),我认为从来没有。 Any help will be greatly appreciated! 任何帮助将不胜感激! 屏幕截图显示标签

Based on Konstantin's suggestion below, I tried to add constraints to the label, but the only ones available are horizontal and vertical centering. 根据康斯坦丁(Konstantin)的以下建议,我尝试在标签上添加约束,但是唯一可用的约束是水平居中和垂直居中。 Others are grayed out. 其他则变灰。 (See screenshot below.) And when I try to select horizontal centering, the Add Constraints button at the bottom remains grayed out, so I can't add it! (请参见下面的屏幕快照。)当我尝试选择水平居中时,底部的“添加约束”按钮仍显示为灰色,因此无法添加它!

在此处输入图片说明

That's because you have width = 0. 那是因为您的width = 0。

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

It may happen when you miss some constrains for Label, which is left from Show More Button 当您错过“ Show More Button留下的一些标签约束时,可能会发生

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

Verify that these label has leading constraints. 验证这些标签是否有前置约束。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM