简体   繁体   English

如何解决UIStackView约束问题

[英]How to fix UIStackView constraint issue

I have the following layout in a UIStackViewView. 我在UIStackViewView中具有以下布局。 It is a image and two labels. 它是一个图像和两个标签。 The design view is what I'd like the runtime view to appear as. 我希望运行时视图显示为设计视图。 But when it runs, everything gets push to the right. 但是,当它运行时,一切都会推向右侧。

在此处输入图片说明

Constraint warnings, which I can't fix: 约束警告,我无法解决:

在此处输入图片说明

Run-time view: 运行时视图:

在此处输入图片说明

Any suggestions how I can fix this? 有什么建议可以解决这个问题吗? The UIStackView is supposed to make complex layouts simpler to manage but I can't even get it to work with just three elements. UIStackView应该使复杂的布局更易于管理,但我什至不能仅使用三个元素就可以使用它。

I guess you are not giving constraints to imageView so its taking all the space to the right. 我猜您没有给imageView施加约束,因此它占用了所有空间。

If you add the aspect-size constraint or give a width constraint then it will constraint the image to the left and get the desired results. 如果添加纵横比大小约束或提供宽度约束,则它将约束图像到左侧并获得所需的结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM