【发布时间】:2018-08-28 02:52:20
【问题描述】:
我创建了一个 tableviewcell。其中有一个图像。我想在列的整个宽度上显示图像。 为此,我添加了所有设置为零的约束: - 领先空间 - 尾随空间 - 顶部空间 - 底部空间 我还定义了一个纵横比约束 8:6 以获得正确的图像纵横比。
在 Interface Builder 中,我收到“需要约束:宽度的 X 位置”的“红色箭头”错误。
当我运行代码(它是可编译的)时,它显示得很好。但是我收到运行时约束警告:
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:0x60800008cfd0 UILayoutGuide:0x6080001a5080'UIViewSafeAreaLayoutGuide'.bottom == UIImageView:0x7fc9fa90fa10.bottom + 8 (active)>",
"<NSLayoutConstraint:0x60800008d2a0 UIImageView:0x7fc9fa90fa10.centerY == UILayoutGuide:0x6080001a5080'UIViewSafeAreaLayoutGuide'.centerY (active)>",
"<NSLayoutConstraint:0x60800008d2f0 UIImageView:0x7fc9fa90fa10.top == UILayoutGuide:0x6080001a5080'UIViewSafeAreaLayoutGuide'.top + 7 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x60800008d2a0 UIImageView:0x7fc9fa90fa10.centerY == UILayoutGuide:0x6080001a5080'UIViewSafeAreaLayoutGuide'.centerY (active)>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
我看不出我做错了什么,有人能指出我正确的方向吗?
【问题讨论】:
标签: objective-c xcode interface-builder constraints