Ios 约束在Xcode中变灰
我正在尝试调试并理解autolayout约束,我注意到在使用xcode调试视图(使用酷层)时,我注意到视图中的一个元素上的约束如下所示 这种观点确实忽略了这些约束 所有约束都具有相同的优先级(1000),因为我需要所有约束。所有约束都是通过interface builder而不是通过代码进行的,IB中没有警告或冲突 但在运行时我确实看到了这一点Ios 约束在Xcode中变灰,ios,objective-c,xcode,autolayout,constraints,Ios,Objective C,Xcode,Autolayout,Constraints,我正在尝试调试并理解autolayout约束,我注意到在使用xcode调试视图(使用酷层)时,我注意到视图中的一个元素上的约束如下所示 这种观点确实忽略了这些约束 所有约束都具有相同的优先级(1000),因为我需要所有约束。所有约束都是通过interface builder而不是通过代码进行的,IB中没有警告或冲突 但在运行时我确实看到了这一点 Unable to simultaneously satisfy constraints. Probably at least one of
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. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSLayoutConstraint:0x79684f10 V:[UIImageView:0x79686800(>=160)]>",
"<NSLayoutConstraint:0x7968a310 V:[UIImageView:0x79686800]-(130.5)-| (Names: '|':UIView:0x79686790 )>",
"<NSLayoutConstraint:0x7968a340 V:|-(0)-[UIImageView:0x79686800] (Names: '|':UIView:0x79686790 )>",
"<NSLayoutConstraint:0x796997b0 'UIView-Encapsulated-Layout-Height' V:[CoverCell:0x79686570(192)]>",
"<NSAutoresizingMaskLayoutConstraint:0x7969cd30 h=-&- v=-&- UIView:0x79686790.height == CoverCell:0x79686570.height>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x79684f10 V:[UIImageView:0x79686800(>=160)]>
无法同时满足约束。
可能下面列表中至少有一个约束是您不想要的。试着这样做:(1)看看每个约束,试着找出你不期望的约束;(2) 找到添加了不需要的约束的代码,然后修复它。(注意:如果您看到不理解的NSAutoresizingMaskLayoutConstraints,请参阅UIView属性TranslatesAutoResizingMaskToConstraints的文档)
(
"=160)]>",
"",
"",
"",
""
)
将尝试通过打破约束进行恢复
=160)]>
因此,从这一点上,我了解到一些规则是冲突的,但我不知道该如何解读
=160
是UIImageView上的一条规则,因此它的高度至少为160,130.5是imageview的底部填充(因此当使用systemLayoutSizeFittingSize:UILayoutFittingCompressedSize时,高度不会为0。因此整个单元格的最小高度为160+130.5)
其余的错误我不明白
约束有什么问题?为什么约束冲突发生在运行时而不是IB中?XCode现在支持不同的布局。例如,这种灰显的约束存在于紧凑的宽度|任何高度布局中,但您当前正在编辑任何宽度|任何高度
更详细的信息:
这要看情况而定。如果不使用尺寸类别,则灰色的将被删除。你需要第二次移除它们。不管听起来多么愚蠢
如果使用大小类,则表示当前大小类与灰色约束的大小类不同。(但是,第一种情况也是可能的…)
在你的情况下,这似乎是第一例。您需要再次删除灰色约束