歧义有两个不等式约束 [英] Ambiguity with two inequality constraints

查看:199
本文介绍了歧义有两个不等式约束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想有底部看法至少是20来自两个图像在它上面的标签了。标签是多行,因此它可以比图像视图高或短,取决于有多少文字有。当我添加两个距离最近的邻居> = 20的约束像截图所示,X code告诉我的约束是模糊的。

I want to have the bottom view be at least 20 away from both the image and the label above it. The label is multiline, so it can be taller or shorter than the image view, depending on how much text there is. When I add two "distance to nearest neighbour >= 20" constraints like shown in the screenshot, Xcode tells me constraints are ambiguous.

如何解决呢?

推荐答案

我觉得你可以像这样做,如果我理解你的要求:

I think you can do it like this, if I understand your requirements:

图片视图具有固定的宽度和高度,和约束到左侧和顶部,以及一个约束到= 20的底视图为700 一个优先。这是至关重要的 - 这将设置底视图的y位置(已固定的高度和约束双方),但将允许它如果具有更高优先级的约束使得走低。具有较高优先级的约束是约束到标签 - 它是> = 20为1000的优先级(该标签还具有约束到顶部,右侧,和图像视图的后缘)

The image view has a fixed width and height, and constraints to the left side and top, as well as a constraint to the bottom view of =20 with a priority of 700. That's crucial -- that will set the y position of that bottom view (which has fixed height and constraints to the two sides), but will allow it to move lower if another constraint with higher priority makes it. That constraint with higher priority is the constraint to the label -- it's >=20 with priority of 1000 (the label also has constraints to the top, right side, and trailing edge of the image view).

这篇关于歧义有两个不等式约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆