如图,我用 A 方法和 B 方法都提示冲突
前提: green view 必须有高度约束的 50
A布局中:
red 距离 super view top 10
green 距离 red view top 10
green 距离 super view bottom 20
此时提示 green 冲突了,不能同时满足 height 和 距离 super view bottom 20
B布局中:
red 距离 super view top 10
green 距离 red view top 10
purple 距离 green view top 0
purple 距离 super view bottom 20
此时还是提示冲突,怎么满足 green view 必须有高度约束呢?
这是一个 uitableviewcell 的布局,bottom也必须要有 Pin,否则自动检测高度无效。
相关代码
titleLabel.autoPinEdgeToSuperviewEdge(ALEdge.Top, withInset: verticalInsets)
titleLabel.autoPinEdgeToSuperviewEdge(ALEdge.Left, withInset: horizontalInsets)
titleLabel.autoPinEdgeToSuperviewEdge(ALEdge.Right, withInset: horizontalInsets)
dateLabel.autoPinEdgeToSuperviewEdge(ALEdge.Left, withInset: horizontalInsets)
dateLabel.autoPinEdge(ALEdge.Top, toEdge: ALEdge.Bottom, ofView: titleLabel, withOffset: verticalInsets / 2)
//
coverImage.autoPinEdge(ALEdge.Top, toEdge: ALEdge.Bottom, ofView: dateLabel, withOffset: verticalInsets)
coverImage.autoPinEdgeToSuperviewEdge(ALEdge.Left, withInset: horizontalInsets)
coverImage.autoPinEdgeToSuperviewEdge(ALEdge.Right, withInset: horizontalInsets)
coverImage.autoSetDimension(ALDimension.Height, toSize: screenWidth * 0.5597014925)
//
bottomGap.autoPinEdge(ALEdge.Top, toEdge: ALEdge.Bottom, ofView: coverImage)
bottomGap.autoPinEdgeToSuperviewEdge(ALEdge.Bottom, withInset: verticalInsets)
1
Shane 2015-01-21 21:38:29 +08:00 via iPhone
定义了top和bottom两个约束,肯定和固定height冲突啊,按你的意思,把top去掉不就可以了,另外,什么叫“自动检测高度无效”
|
2
cralison 2015-01-22 04:19:03 +08:00
是这样的,height不能同时设top和bottom,width不能同时设leading和trailing,因为这从逻辑上就说不通。
|