简体   繁体   English

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

[英]Need constraints for y position, height - Auto layout Storyboard

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

I was getting red warning in layout for need constraints for y position, height and any how I want to resolve this.我在布局中收到红色警告,需要对 y 位置、高度以及我想如何解决此问题的任何限制。 Following image will make you more clear regarding this:下图将使您更清楚地了解这一点:

在此处输入图片说明

Specifically I was getting problem in video view and button below that regarding y position constraints.具体来说,我在视频视图和按钮下方遇到了关于 y 位置约束的问题。

在此处输入图片说明

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.我在进行布局时多次遇到同样的问题,所以如果我学习了这个解决方案,那么对我来说将是一个很大的解脱。

You need to set the VideoView Height constraint.您需要设置 VideoView 高度约束。

Steps:步骤:

  1. Select the VideoView.选择视频视图。

  2. Click in "Add New Constraints" next to "Align" and after "Resolve Auto Layout Issues" option.单击“对齐”旁边的“添加新约束”,然后单击“解决自动布局问题”选项。

  3. Set the height constant you want.设置您想要的高度常数。

  4. Check the height box.检查高度框。

  5. You also need set the Y position, because the VideoView don't know what is below and above.您还需要设置 Y 位置,因为 VideoView 不知道下方和上方是什么。 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因此,单击顶部约束使其看起来为红色,在 topView 和 VideoView 之间设置所需的空间(在我的图像示例中:0)顶部约束的证据

  6. Click "Add 1 constraint"单击“添加 1 个约束”

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.希望这对你有帮助。

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

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