[英]ios - How to auto-resize my view in storyboard? swift 3
I try to auto-resize my view with auto-layout contraints, but I have some errors of Y-position missing. 我尝试使用自动布局约束自动调整视图大小,但是我缺少一些Y位置错误。 I can't understand what is wrong, I attached my Y-position to the top of the view.
我不明白哪里出了问题,我将Y位置附加到视图顶部。
Thanks for your help, here is the screenshot: 感谢您的帮助,以下是屏幕截图:
The problem is that you don't set a fixed height but, if you can, ALWAYS AVOID to put a fixed height for a view. 问题是您没有设置固定的高度,但是,如果可以的话,请始终避免为视图设置固定的高度。 For an app that can fit all screen is better to use different techniques.
对于适合所有屏幕的应用,最好使用不同的技术。 If don't want to set a fixed height on your view, you have two possible options:
如果不想在视图上设置固定高度,则有两个可能的选择:
You must give a height for the view or construct it's subviews in a way that gives it a height by hooking constraints properly from top to bottom 您必须为视图提供高度或以子视图的方式构造子视图,从而通过适当地上下挂钩约束来赋予其高度
when you have ay position error it means top, bottom and height issue 当您遇到ay位置错误时,这意味着顶部,底部和高度问题
and when x it means leading , trailing and width issue 当x表示前导,尾随和宽度问题
IF you want to create dynamic view drag a vertical UIStackView and give it a height and in runtime add items to it 如果要创建动态视图,请拖动垂直的UIStackView并赋予其高度,然后在运行时向其中添加项目
self.myStackView.addArrangedSubview(lbl)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.