自动布局 - 无法满足约束
Autolayout - Unable to satisfy constraints
更新:所以我尝试添加堆栈视图并注意到一个有趣的现象。似乎当我有最后一个图像视图或堆栈视图的边缘有一个到 superview = -1(Xcode 默认值)的后缘时,它会拉伸所有内容并破坏图像。但是如果我没有那个约束,它不会将它们均匀地分布在单元格上,但所有图像都适合......我如何实现两者的结合!!!
好吧,只是作为序言,这是开始所有这一切的原始问题:
我选择了公认的答案,并获得了一个看起来几乎正确的答案:
现在的问题是它由于某种原因打破了限制,图像不再是完美的圆形了。
我收到了 5 组破坏约束的警告。据我所知,它打破了每个图像视图的 55 宽度。
我是自动布局的新手,完全不明白为什么会发生这种情况。我将在下面粘贴输出,如果您需要更多信息,请告诉我。
第一
"<NSLayoutConstraint:0x7ffc2c0f5420 V:[UIImageView:0x7ffc2c035030(55)]>",
"<NSLayoutConstraint:0x7ffc2c0f5470 UIImageView:0x7ffc2c035030.width == UIImageView:0x7ffc2c035030.height>",
"<NSLayoutConstraint:0x7ffc2c0f5570 V:[UIImageView:0x7ffc2c094a60(55)]>",
"<NSLayoutConstraint:0x7ffc2c0f5640 UIImageView:0x7ffc2c094a60.width == UIImageView:0x7ffc2c094a60.height>",
"<NSLayoutConstraint:0x7ffc2c0f5750 UIImageView:0x7ffc29deea00.width == UIImageView:0x7ffc29deea00.height>",
"<NSLayoutConstraint:0x7ffc2c0f57a0 V:[UIImageView:0x7ffc29deea00(55)]>",
"<NSLayoutConstraint:0x7ffc2c0f5860 V:[UIImageView:0x7ffc2c0e7b20(55)]>",
"<NSLayoutConstraint:0x7ffc2c0f58b0 UIImageView:0x7ffc2c0e7b20.width == UIImageView:0x7ffc2c0e7b20.height>",
"<NSLayoutConstraint:0x7ffc2c0f5970 V:[UIImageView:0x7ffc2c0d7860(55)]>",
"<NSLayoutConstraint:0x7ffc2c0f59c0 UIImageView:0x7ffc2c0d7860.width == UIImageView:0x7ffc2c0d7860.height>",
"<NSLayoutConstraint:0x7ffc2c0f60e0 UIImageView:0x7ffc2c035030.leading == UITableViewCellContentView:0x7ffc2c08ccc0.leadingMargin>",
"<NSLayoutConstraint:0x7ffc2c0f6130 H:[UIImageView:0x7ffc2c035030]-(8)-[UIImageView:0x7ffc2c094a60]>",
"<NSLayoutConstraint:0x7ffc2c0f6300 H:[UIImageView:0x7ffc2c094a60]-(8)-[UIImageView:0x7ffc29deea00]>",
"<NSLayoutConstraint:0x7ffc2c0f6460 H:[UIImageView:0x7ffc29deea00]-(8)-[UIImageView:0x7ffc2c0d7860]>",
"<NSLayoutConstraint:0x7ffc2c0f6630 H:[UIImageView:0x7ffc2c0d7860]-(8)-[UIImageView:0x7ffc2c0e7b20]>",
"<NSLayoutConstraint:0x7ffc2c0f6740 UITableViewCellContentView:0x7ffc2c08ccc0.trailingMargin == UIImageView:0x7ffc2c0e7b20.trailing - 1>",
"<NSLayoutConstraint:0x7ffc2c130dd0 'fittingSizeHTarget' H:[UITableViewCellContentView:0x7ffc2c08ccc0(375)]>"
Will attempt to recover by breaking constraint <NSLayoutConstraint:0x7ffc2c0f5970 V:[UIImageView:0x7ffc2c0d7860(55)]>
第二
"<NSLayoutConstraint:0x7ffc2c0f5420 V:[UIImageView:0x7ffc2c035030(55)]>",
"<NSLayoutConstraint:0x7ffc2c0f5470 UIImageView:0x7ffc2c035030.width == UIImageView:0x7ffc2c035030.height>",
"<NSLayoutConstraint:0x7ffc2c0f5570 V:[UIImageView:0x7ffc2c094a60(55)]>",
"<NSLayoutConstraint:0x7ffc2c0f5640 UIImageView:0x7ffc2c094a60.width == UIImageView:0x7ffc2c094a60.height>",
"<NSLayoutConstraint:0x7ffc2c0f5750 UIImageView:0x7ffc29deea00.width == UIImageView:0x7ffc29deea00.height>",
"<NSLayoutConstraint:0x7ffc2c0f57a0 V:[UIImageView:0x7ffc29deea00(55)]>",
"<NSLayoutConstraint:0x7ffc2c0f5860 V:[UIImageView:0x7ffc2c0e7b20(55)]>",
"<NSLayoutConstraint:0x7ffc2c0f58b0 UIImageView:0x7ffc2c0e7b20.width == UIImageView:0x7ffc2c0e7b20.height>",
"<NSLayoutConstraint:0x7ffc2c0f60e0 UIImageView:0x7ffc2c035030.leading == UITableViewCellContentView:0x7ffc2c08ccc0.leadingMargin>",
"<NSLayoutConstraint:0x7ffc2c0f6130 H:[UIImageView:0x7ffc2c035030]-(8)-[UIImageView:0x7ffc2c094a60]>",
"<NSLayoutConstraint:0x7ffc2c0f6300 H:[UIImageView:0x7ffc2c094a60]-(8)-[UIImageView:0x7ffc29deea00]>",
"<NSLayoutConstraint:0x7ffc2c0f6460 H:[UIImageView:0x7ffc29deea00]-(8)-[UIImageView:0x7ffc2c0d7860]>",
"<NSLayoutConstraint:0x7ffc2c0f6630 H:[UIImageView:0x7ffc2c0d7860]-(8)-[UIImageView:0x7ffc2c0e7b20]>",
"<NSLayoutConstraint:0x7ffc2c0f6740 UITableViewCellContentView:0x7ffc2c08ccc0.trailingMargin == UIImageView:0x7ffc2c0e7b20.trailing - 1>",
"<NSLayoutConstraint:0x7ffc2c0f6570 UIImageView:0x7ffc2c0d7860.width == UIImageView:0x7ffc2c035030.width>",
"<NSLayoutConstraint:0x7ffc2c130dd0 'fittingSizeHTarget' H:[UITableViewCellContentView:0x7ffc2c08ccc0(375)]>"
Will attempt to recover by breaking constraint <NSLayoutConstraint:0x7ffc2c0f5860 V:[UIImageView:0x7ffc2c0e7b20(55)]>
第三
"<NSLayoutConstraint:0x7ffc2c0f5420 V:[UIImageView:0x7ffc2c035030(55)]>",
"<NSLayoutConstraint:0x7ffc2c0f5470 UIImageView:0x7ffc2c035030.width == UIImageView:0x7ffc2c035030.height>",
"<NSLayoutConstraint:0x7ffc2c0f5570 V:[UIImageView:0x7ffc2c094a60(55)]>",
"<NSLayoutConstraint:0x7ffc2c0f5640 UIImageView:0x7ffc2c094a60.width == UIImageView:0x7ffc2c094a60.height>",
"<NSLayoutConstraint:0x7ffc2c0f5750 UIImageView:0x7ffc29deea00.width == UIImageView:0x7ffc29deea00.height>",
"<NSLayoutConstraint:0x7ffc2c0f57a0 V:[UIImageView:0x7ffc29deea00(55)]>",
"<NSLayoutConstraint:0x7ffc2c0f60e0 UIImageView:0x7ffc2c035030.leading == UITableViewCellContentView:0x7ffc2c08ccc0.leadingMargin>",
"<NSLayoutConstraint:0x7ffc2c0f6130 H:[UIImageView:0x7ffc2c035030]-(8)-[UIImageView:0x7ffc2c094a60]>",
"<NSLayoutConstraint:0x7ffc2c0f6300 H:[UIImageView:0x7ffc2c094a60]-(8)-[UIImageView:0x7ffc29deea00]>",
"<NSLayoutConstraint:0x7ffc2c0f6460 H:[UIImageView:0x7ffc29deea00]-(8)-[UIImageView:0x7ffc2c0d7860]>",
"<NSLayoutConstraint:0x7ffc2c0f6570 UIImageView:0x7ffc2c0d7860.width == UIImageView:0x7ffc2c035030.width>",
"<NSLayoutConstraint:0x7ffc2c0f6630 H:[UIImageView:0x7ffc2c0d7860]-(8)-[UIImageView:0x7ffc2c0e7b20]>",
"<NSLayoutConstraint:0x7ffc2c0f6740 UITableViewCellContentView:0x7ffc2c08ccc0.trailingMargin == UIImageView:0x7ffc2c0e7b20.trailing - 1>",
"<NSLayoutConstraint:0x7ffc2c0f6790 UIImageView:0x7ffc2c0e7b20.width == UIImageView:0x7ffc2c035030.width>",
"<NSLayoutConstraint:0x7ffc2c130dd0 'fittingSizeHTarget' H:[UITableViewCellContentView:0x7ffc2c08ccc0(375)]>"
Will attempt to recover by breaking constraint <NSLayoutConstraint:0x7ffc2c0f57a0 V:[UIImageView:0x7ffc29deea00(55)]>
第四
"<NSLayoutConstraint:0x7ffc2c0f5420 V:[UIImageView:0x7ffc2c035030(55)]>",
"<NSLayoutConstraint:0x7ffc2c0f5470 UIImageView:0x7ffc2c035030.width == UIImageView:0x7ffc2c035030.height>",
"<NSLayoutConstraint:0x7ffc2c0f5570 V:[UIImageView:0x7ffc2c094a60(55)]>",
"<NSLayoutConstraint:0x7ffc2c0f5640 UIImageView:0x7ffc2c094a60.width == UIImageView:0x7ffc2c094a60.height>",
"<NSLayoutConstraint:0x7ffc2c0f60e0 UIImageView:0x7ffc2c035030.leading == UITableViewCellContentView:0x7ffc2c08ccc0.leadingMargin>",
"<NSLayoutConstraint:0x7ffc2c0f6130 H:[UIImageView:0x7ffc2c035030]-(8)-[UIImageView:0x7ffc2c094a60]>",
"<NSLayoutConstraint:0x7ffc2c0f6300 H:[UIImageView:0x7ffc2c094a60]-(8)-[UIImageView:0x7ffc29deea00]>",
"<NSLayoutConstraint:0x7ffc2c0f6460 H:[UIImageView:0x7ffc29deea00]-(8)-[UIImageView:0x7ffc2c0d7860]>",
"<NSLayoutConstraint:0x7ffc2c0f6570 UIImageView:0x7ffc2c0d7860.width == UIImageView:0x7ffc2c035030.width>",
"<NSLayoutConstraint:0x7ffc2c0f6630 H:[UIImageView:0x7ffc2c0d7860]-(8)-[UIImageView:0x7ffc2c0e7b20]>",
"<NSLayoutConstraint:0x7ffc2c0f6740 UITableViewCellContentView:0x7ffc2c08ccc0.trailingMargin == UIImageView:0x7ffc2c0e7b20.trailing - 1>",
"<NSLayoutConstraint:0x7ffc2c0f6790 UIImageView:0x7ffc2c0e7b20.width == UIImageView:0x7ffc2c035030.width>",
"<NSLayoutConstraint:0x7ffc2c0f6350 UIImageView:0x7ffc29deea00.width == UIImageView:0x7ffc2c035030.width>",
"<NSLayoutConstraint:0x7ffc2c130dd0 'fittingSizeHTarget' H:[UITableViewCellContentView:0x7ffc2c08ccc0(375)]>"
Will attempt to recover by breaking constraint <NSLayoutConstraint:0x7ffc2c0f5570 V:[UIImageView:0x7ffc2c094a60(55)]>
第五名
"<NSLayoutConstraint:0x7ffc2c0f5420 V:[UIImageView:0x7ffc2c035030(55)]>",
"<NSLayoutConstraint:0x7ffc2c0f5470 UIImageView:0x7ffc2c035030.width == UIImageView:0x7ffc2c035030.height>",
"<NSLayoutConstraint:0x7ffc2c0f60e0 UIImageView:0x7ffc2c035030.leading == UITableViewCellContentView:0x7ffc2c08ccc0.leadingMargin>",
"<NSLayoutConstraint:0x7ffc2c0f6130 H:[UIImageView:0x7ffc2c035030]-(8)-[UIImageView:0x7ffc2c094a60]>",
"<NSLayoutConstraint:0x7ffc2c0f6300 H:[UIImageView:0x7ffc2c094a60]-(8)-[UIImageView:0x7ffc29deea00]>",
"<NSLayoutConstraint:0x7ffc2c0f6350 UIImageView:0x7ffc29deea00.width == UIImageView:0x7ffc2c035030.width>",
"<NSLayoutConstraint:0x7ffc2c0f6460 H:[UIImageView:0x7ffc29deea00]-(8)-[UIImageView:0x7ffc2c0d7860]>",
"<NSLayoutConstraint:0x7ffc2c0f6570 UIImageView:0x7ffc2c0d7860.width == UIImageView:0x7ffc2c035030.width>",
"<NSLayoutConstraint:0x7ffc2c0f6630 H:[UIImageView:0x7ffc2c0d7860]-(8)-[UIImageView:0x7ffc2c0e7b20]>",
"<NSLayoutConstraint:0x7ffc2c0f6740 UITableViewCellContentView:0x7ffc2c08ccc0.trailingMargin == UIImageView:0x7ffc2c0e7b20.trailing - 1>",
"<NSLayoutConstraint:0x7ffc2c0f6790 UIImageView:0x7ffc2c0e7b20.width == UIImageView:0x7ffc2c035030.width>",
"<NSLayoutConstraint:0x7ffc2c0f6240 UIImageView:0x7ffc2c094a60.width == UIImageView:0x7ffc2c035030.width>",
"<NSLayoutConstraint:0x7ffc2c130dd0 'fittingSizeHTarget' H:[UITableViewCellContentView:0x7ffc2c08ccc0(375)]>"
Will attempt to recover by breaking constraint <NSLayoutConstraint:0x7ffc2c0f5420 V:[UIImageView:0x7ffc2c035030(55)]>
据我所知,图像视图似乎对它们与下方按钮和上方标签的对齐方式不满意。
谢谢
安迪
你过度限制了你的观点。
您有一个约束,告诉您的图像视图具有 55 的高度和 1.0 的纵横比,因此它们的宽度也为 55。图片的 5 * 55 加上间距的 4 * 8 为您的视图提供了 315 的总宽度,但屏幕不是 315 宽,因此系统必须打破您的一些限制(它选择打破 55在这种情况下高度为一)。
您需要删除 55 高度限制,以便图像视图可以根据填充屏幕所需的宽度增加尺寸,或者更改间距限制,以便它们可以增加图像之间的间距视图在保持相同尺寸的同时填满屏幕。
所以我想通了...
具有相等间距的堆栈视图,以及前导 space 到边距使得间距约束根据需要随着不同的宽度而变化。为每个图像视图添加简单的纵横比和高度使其工作。
更新:所以我尝试添加堆栈视图并注意到一个有趣的现象。似乎当我有最后一个图像视图或堆栈视图的边缘有一个到 superview = -1(Xcode 默认值)的后缘时,它会拉伸所有内容并破坏图像。但是如果我没有那个约束,它不会将它们均匀地分布在单元格上,但所有图像都适合......我如何实现两者的结合!!!
好吧,只是作为序言,这是开始所有这一切的原始问题:
我选择了公认的答案,并获得了一个看起来几乎正确的答案:
现在的问题是它由于某种原因打破了限制,图像不再是完美的圆形了。
我收到了 5 组破坏约束的警告。据我所知,它打破了每个图像视图的 55 宽度。
我是自动布局的新手,完全不明白为什么会发生这种情况。我将在下面粘贴输出,如果您需要更多信息,请告诉我。
第一
"<NSLayoutConstraint:0x7ffc2c0f5420 V:[UIImageView:0x7ffc2c035030(55)]>",
"<NSLayoutConstraint:0x7ffc2c0f5470 UIImageView:0x7ffc2c035030.width == UIImageView:0x7ffc2c035030.height>",
"<NSLayoutConstraint:0x7ffc2c0f5570 V:[UIImageView:0x7ffc2c094a60(55)]>",
"<NSLayoutConstraint:0x7ffc2c0f5640 UIImageView:0x7ffc2c094a60.width == UIImageView:0x7ffc2c094a60.height>",
"<NSLayoutConstraint:0x7ffc2c0f5750 UIImageView:0x7ffc29deea00.width == UIImageView:0x7ffc29deea00.height>",
"<NSLayoutConstraint:0x7ffc2c0f57a0 V:[UIImageView:0x7ffc29deea00(55)]>",
"<NSLayoutConstraint:0x7ffc2c0f5860 V:[UIImageView:0x7ffc2c0e7b20(55)]>",
"<NSLayoutConstraint:0x7ffc2c0f58b0 UIImageView:0x7ffc2c0e7b20.width == UIImageView:0x7ffc2c0e7b20.height>",
"<NSLayoutConstraint:0x7ffc2c0f5970 V:[UIImageView:0x7ffc2c0d7860(55)]>",
"<NSLayoutConstraint:0x7ffc2c0f59c0 UIImageView:0x7ffc2c0d7860.width == UIImageView:0x7ffc2c0d7860.height>",
"<NSLayoutConstraint:0x7ffc2c0f60e0 UIImageView:0x7ffc2c035030.leading == UITableViewCellContentView:0x7ffc2c08ccc0.leadingMargin>",
"<NSLayoutConstraint:0x7ffc2c0f6130 H:[UIImageView:0x7ffc2c035030]-(8)-[UIImageView:0x7ffc2c094a60]>",
"<NSLayoutConstraint:0x7ffc2c0f6300 H:[UIImageView:0x7ffc2c094a60]-(8)-[UIImageView:0x7ffc29deea00]>",
"<NSLayoutConstraint:0x7ffc2c0f6460 H:[UIImageView:0x7ffc29deea00]-(8)-[UIImageView:0x7ffc2c0d7860]>",
"<NSLayoutConstraint:0x7ffc2c0f6630 H:[UIImageView:0x7ffc2c0d7860]-(8)-[UIImageView:0x7ffc2c0e7b20]>",
"<NSLayoutConstraint:0x7ffc2c0f6740 UITableViewCellContentView:0x7ffc2c08ccc0.trailingMargin == UIImageView:0x7ffc2c0e7b20.trailing - 1>",
"<NSLayoutConstraint:0x7ffc2c130dd0 'fittingSizeHTarget' H:[UITableViewCellContentView:0x7ffc2c08ccc0(375)]>"
Will attempt to recover by breaking constraint <NSLayoutConstraint:0x7ffc2c0f5970 V:[UIImageView:0x7ffc2c0d7860(55)]>
第二
"<NSLayoutConstraint:0x7ffc2c0f5420 V:[UIImageView:0x7ffc2c035030(55)]>",
"<NSLayoutConstraint:0x7ffc2c0f5470 UIImageView:0x7ffc2c035030.width == UIImageView:0x7ffc2c035030.height>",
"<NSLayoutConstraint:0x7ffc2c0f5570 V:[UIImageView:0x7ffc2c094a60(55)]>",
"<NSLayoutConstraint:0x7ffc2c0f5640 UIImageView:0x7ffc2c094a60.width == UIImageView:0x7ffc2c094a60.height>",
"<NSLayoutConstraint:0x7ffc2c0f5750 UIImageView:0x7ffc29deea00.width == UIImageView:0x7ffc29deea00.height>",
"<NSLayoutConstraint:0x7ffc2c0f57a0 V:[UIImageView:0x7ffc29deea00(55)]>",
"<NSLayoutConstraint:0x7ffc2c0f5860 V:[UIImageView:0x7ffc2c0e7b20(55)]>",
"<NSLayoutConstraint:0x7ffc2c0f58b0 UIImageView:0x7ffc2c0e7b20.width == UIImageView:0x7ffc2c0e7b20.height>",
"<NSLayoutConstraint:0x7ffc2c0f60e0 UIImageView:0x7ffc2c035030.leading == UITableViewCellContentView:0x7ffc2c08ccc0.leadingMargin>",
"<NSLayoutConstraint:0x7ffc2c0f6130 H:[UIImageView:0x7ffc2c035030]-(8)-[UIImageView:0x7ffc2c094a60]>",
"<NSLayoutConstraint:0x7ffc2c0f6300 H:[UIImageView:0x7ffc2c094a60]-(8)-[UIImageView:0x7ffc29deea00]>",
"<NSLayoutConstraint:0x7ffc2c0f6460 H:[UIImageView:0x7ffc29deea00]-(8)-[UIImageView:0x7ffc2c0d7860]>",
"<NSLayoutConstraint:0x7ffc2c0f6630 H:[UIImageView:0x7ffc2c0d7860]-(8)-[UIImageView:0x7ffc2c0e7b20]>",
"<NSLayoutConstraint:0x7ffc2c0f6740 UITableViewCellContentView:0x7ffc2c08ccc0.trailingMargin == UIImageView:0x7ffc2c0e7b20.trailing - 1>",
"<NSLayoutConstraint:0x7ffc2c0f6570 UIImageView:0x7ffc2c0d7860.width == UIImageView:0x7ffc2c035030.width>",
"<NSLayoutConstraint:0x7ffc2c130dd0 'fittingSizeHTarget' H:[UITableViewCellContentView:0x7ffc2c08ccc0(375)]>"
Will attempt to recover by breaking constraint <NSLayoutConstraint:0x7ffc2c0f5860 V:[UIImageView:0x7ffc2c0e7b20(55)]>
第三
"<NSLayoutConstraint:0x7ffc2c0f5420 V:[UIImageView:0x7ffc2c035030(55)]>",
"<NSLayoutConstraint:0x7ffc2c0f5470 UIImageView:0x7ffc2c035030.width == UIImageView:0x7ffc2c035030.height>",
"<NSLayoutConstraint:0x7ffc2c0f5570 V:[UIImageView:0x7ffc2c094a60(55)]>",
"<NSLayoutConstraint:0x7ffc2c0f5640 UIImageView:0x7ffc2c094a60.width == UIImageView:0x7ffc2c094a60.height>",
"<NSLayoutConstraint:0x7ffc2c0f5750 UIImageView:0x7ffc29deea00.width == UIImageView:0x7ffc29deea00.height>",
"<NSLayoutConstraint:0x7ffc2c0f57a0 V:[UIImageView:0x7ffc29deea00(55)]>",
"<NSLayoutConstraint:0x7ffc2c0f60e0 UIImageView:0x7ffc2c035030.leading == UITableViewCellContentView:0x7ffc2c08ccc0.leadingMargin>",
"<NSLayoutConstraint:0x7ffc2c0f6130 H:[UIImageView:0x7ffc2c035030]-(8)-[UIImageView:0x7ffc2c094a60]>",
"<NSLayoutConstraint:0x7ffc2c0f6300 H:[UIImageView:0x7ffc2c094a60]-(8)-[UIImageView:0x7ffc29deea00]>",
"<NSLayoutConstraint:0x7ffc2c0f6460 H:[UIImageView:0x7ffc29deea00]-(8)-[UIImageView:0x7ffc2c0d7860]>",
"<NSLayoutConstraint:0x7ffc2c0f6570 UIImageView:0x7ffc2c0d7860.width == UIImageView:0x7ffc2c035030.width>",
"<NSLayoutConstraint:0x7ffc2c0f6630 H:[UIImageView:0x7ffc2c0d7860]-(8)-[UIImageView:0x7ffc2c0e7b20]>",
"<NSLayoutConstraint:0x7ffc2c0f6740 UITableViewCellContentView:0x7ffc2c08ccc0.trailingMargin == UIImageView:0x7ffc2c0e7b20.trailing - 1>",
"<NSLayoutConstraint:0x7ffc2c0f6790 UIImageView:0x7ffc2c0e7b20.width == UIImageView:0x7ffc2c035030.width>",
"<NSLayoutConstraint:0x7ffc2c130dd0 'fittingSizeHTarget' H:[UITableViewCellContentView:0x7ffc2c08ccc0(375)]>"
Will attempt to recover by breaking constraint <NSLayoutConstraint:0x7ffc2c0f57a0 V:[UIImageView:0x7ffc29deea00(55)]>
第四
"<NSLayoutConstraint:0x7ffc2c0f5420 V:[UIImageView:0x7ffc2c035030(55)]>",
"<NSLayoutConstraint:0x7ffc2c0f5470 UIImageView:0x7ffc2c035030.width == UIImageView:0x7ffc2c035030.height>",
"<NSLayoutConstraint:0x7ffc2c0f5570 V:[UIImageView:0x7ffc2c094a60(55)]>",
"<NSLayoutConstraint:0x7ffc2c0f5640 UIImageView:0x7ffc2c094a60.width == UIImageView:0x7ffc2c094a60.height>",
"<NSLayoutConstraint:0x7ffc2c0f60e0 UIImageView:0x7ffc2c035030.leading == UITableViewCellContentView:0x7ffc2c08ccc0.leadingMargin>",
"<NSLayoutConstraint:0x7ffc2c0f6130 H:[UIImageView:0x7ffc2c035030]-(8)-[UIImageView:0x7ffc2c094a60]>",
"<NSLayoutConstraint:0x7ffc2c0f6300 H:[UIImageView:0x7ffc2c094a60]-(8)-[UIImageView:0x7ffc29deea00]>",
"<NSLayoutConstraint:0x7ffc2c0f6460 H:[UIImageView:0x7ffc29deea00]-(8)-[UIImageView:0x7ffc2c0d7860]>",
"<NSLayoutConstraint:0x7ffc2c0f6570 UIImageView:0x7ffc2c0d7860.width == UIImageView:0x7ffc2c035030.width>",
"<NSLayoutConstraint:0x7ffc2c0f6630 H:[UIImageView:0x7ffc2c0d7860]-(8)-[UIImageView:0x7ffc2c0e7b20]>",
"<NSLayoutConstraint:0x7ffc2c0f6740 UITableViewCellContentView:0x7ffc2c08ccc0.trailingMargin == UIImageView:0x7ffc2c0e7b20.trailing - 1>",
"<NSLayoutConstraint:0x7ffc2c0f6790 UIImageView:0x7ffc2c0e7b20.width == UIImageView:0x7ffc2c035030.width>",
"<NSLayoutConstraint:0x7ffc2c0f6350 UIImageView:0x7ffc29deea00.width == UIImageView:0x7ffc2c035030.width>",
"<NSLayoutConstraint:0x7ffc2c130dd0 'fittingSizeHTarget' H:[UITableViewCellContentView:0x7ffc2c08ccc0(375)]>"
Will attempt to recover by breaking constraint <NSLayoutConstraint:0x7ffc2c0f5570 V:[UIImageView:0x7ffc2c094a60(55)]>
第五名
"<NSLayoutConstraint:0x7ffc2c0f5420 V:[UIImageView:0x7ffc2c035030(55)]>",
"<NSLayoutConstraint:0x7ffc2c0f5470 UIImageView:0x7ffc2c035030.width == UIImageView:0x7ffc2c035030.height>",
"<NSLayoutConstraint:0x7ffc2c0f60e0 UIImageView:0x7ffc2c035030.leading == UITableViewCellContentView:0x7ffc2c08ccc0.leadingMargin>",
"<NSLayoutConstraint:0x7ffc2c0f6130 H:[UIImageView:0x7ffc2c035030]-(8)-[UIImageView:0x7ffc2c094a60]>",
"<NSLayoutConstraint:0x7ffc2c0f6300 H:[UIImageView:0x7ffc2c094a60]-(8)-[UIImageView:0x7ffc29deea00]>",
"<NSLayoutConstraint:0x7ffc2c0f6350 UIImageView:0x7ffc29deea00.width == UIImageView:0x7ffc2c035030.width>",
"<NSLayoutConstraint:0x7ffc2c0f6460 H:[UIImageView:0x7ffc29deea00]-(8)-[UIImageView:0x7ffc2c0d7860]>",
"<NSLayoutConstraint:0x7ffc2c0f6570 UIImageView:0x7ffc2c0d7860.width == UIImageView:0x7ffc2c035030.width>",
"<NSLayoutConstraint:0x7ffc2c0f6630 H:[UIImageView:0x7ffc2c0d7860]-(8)-[UIImageView:0x7ffc2c0e7b20]>",
"<NSLayoutConstraint:0x7ffc2c0f6740 UITableViewCellContentView:0x7ffc2c08ccc0.trailingMargin == UIImageView:0x7ffc2c0e7b20.trailing - 1>",
"<NSLayoutConstraint:0x7ffc2c0f6790 UIImageView:0x7ffc2c0e7b20.width == UIImageView:0x7ffc2c035030.width>",
"<NSLayoutConstraint:0x7ffc2c0f6240 UIImageView:0x7ffc2c094a60.width == UIImageView:0x7ffc2c035030.width>",
"<NSLayoutConstraint:0x7ffc2c130dd0 'fittingSizeHTarget' H:[UITableViewCellContentView:0x7ffc2c08ccc0(375)]>"
Will attempt to recover by breaking constraint <NSLayoutConstraint:0x7ffc2c0f5420 V:[UIImageView:0x7ffc2c035030(55)]>
据我所知,图像视图似乎对它们与下方按钮和上方标签的对齐方式不满意。
谢谢
安迪
你过度限制了你的观点。
您有一个约束,告诉您的图像视图具有 55 的高度和 1.0 的纵横比,因此它们的宽度也为 55。图片的 5 * 55 加上间距的 4 * 8 为您的视图提供了 315 的总宽度,但屏幕不是 315 宽,因此系统必须打破您的一些限制(它选择打破 55在这种情况下高度为一)。
您需要删除 55 高度限制,以便图像视图可以根据填充屏幕所需的宽度增加尺寸,或者更改间距限制,以便它们可以增加图像之间的间距视图在保持相同尺寸的同时填满屏幕。
所以我想通了...
具有相等间距的堆栈视图,以及前导 space 到边距使得间距约束根据需要随着不同的宽度而变化。为每个图像视图添加简单的纵横比和高度使其工作。