xcode 需要 y 位置、高度的约束 - 自动布局故事板

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/49616619/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 10:36:09  来源:igfitidea点击:

Need constraints for y position, height - Auto layout Storyboard

iosxcodeuistoryboardios-autolayout

提问by Siddharth

First let me tell that I have gone through multiple same kind of questions available in Stack Overflow but neither of them helped me.

首先让我告诉我,我已经解决了 Stack Overflow 中提供的多个相同类型的问题,但它们都没有帮助我。

So I created new question for discussing my problem.

所以我创建了新问题来讨论我的问题。

I am beginner with iOS programming and with layout making in Storyboard so daily facing few problem in designing. With this problem, I already spent my 2 days but may be its really easy for an expert person to help me in this problem.

我是 iOS 编程的初学者,并且在 Storyboard 中进行布局制作,所以每天在设计中遇到很少的问题。对于这个问题,我已经花了 2 天的时间,但专家帮助我解决这个问题可能真的很容易。

I was getting red warning in layout for need constraints for y position, height and any how I want to resolve this. Following image will make you more clear regarding this:

我在布局中收到红色警告,需要对 y 位置、高度以及我想如何解决此问题的任何限制。下图将使您更清楚地了解这一点:

enter image description here

在此处输入图片说明

Specifically I was getting problem in video view and button below that regarding y position constraints.

具体来说,我在视频视图和按钮下方遇到了关于 y 位置约束的问题。

enter image description here

在此处输入图片说明

So please suggest me, how to solve this problem? I was getting same problem multiple times when I was making layout so if I learn this solution then it will be big relief for me.

所以请建议我,如何解决这个问题?我在进行布局时多次遇到同样的问题,所以如果我学习了这个解决方案,那么对我来说将是一个很大的解脱。

回答by Laura Mejia Arroyave

You need to set the VideoView Height constraint.

您需要设置 VideoView 高度约束。

Steps:

脚步:

1.Select the VideoView.

1.选择视频视图。

2.Click in "Add New Constraints" next to "Align" and after "Resolve Auto Layout Issues" option.

2.单击“对齐”旁边的“添加新约束”和“解决自动布局问题”选项之后。

3.Set the height constant you want.

3.设置您想要的高度常数。

4.Check the height box.

4.检查高度框。

5.You also need set the Y position, because the VideoView don't know what is below and above. So, click the top constraint to make it look red, set the space that you need between your topView and the VideoView (in this case of my image example: 0)evidency of top constraint

5.你还需要设置 Y 位置,因为 VideoView 不知道下面和上面是什么。因此,单击顶部约束使其看起来为红色,设置 topView 和 VideoView 之间所需的空间(在我的图像示例中:0)顶部约束的证据

6.Click "Add 1 constraint"

6.点击“添加1个约束”

回答by jay sharma

You can give the constraints in the different ways as per your requirement:

您可以根据您的要求以不同的方式给出约束:

1) Select your video view

1) 选择您的视频视图

2) Add new constraint and add the top constraint (Constraint between your Video view and top view, in your case the view with text surfa)

2)添加新约束并添加顶部约束(视频视图和顶部视图之间的约束,在您的情况下是带有文本表面的视图)

3) Select bottom constraint (if bottom buttons hight is fixed)

3)选择底部约束(如果底部按钮高度是固定的)

or

或者

3) Select the height constraint (if you want to fix your video view height)

3)选择高度约束(如果你想固定你的视频视图高度)

or

或者

3) You can give the aspect ratio to video view (In this situation your view's height will be change as per the screen size)

3)您可以为视频视图提供纵横比(在这种情况下,您的视图高度将根据屏幕尺寸而变化)

Hope this will be helpful to you.

希望这对你有帮助。