为什么故事板中的按钮未位于 ios8 中的适当位置? [英] Why button in storyboard is not located in appropriate location in ios8?

查看:22
本文介绍了为什么故事板中的按钮未位于 ios8 中的适当位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的故事板的设计:

这里是输出:

为什么这个按钮没有放在正确的位置?

解决方案

这是 Stack Overflow 上的一个常见问题.您需要为按钮添加自动布局约束.它不知道您的意思是在中心"还是距左侧 300 点".您可以通过选择按钮并点击编辑器右下角带有正方形的按钮来添加它们.

这些是按钮.

按钮是...

  1. 对齐视图.多个视图或单个视图及其父视图.
  2. 向特定视图添加约束.左侧、顶部、高度、宽度等...
  3. 自动约束.将框架更新为约束.等等...
  4. 调整大小选项.

您需要为应用中的所有视图添加约束.

因此,在 button2 上,您需要告诉它...

<块引用>

  1. 离顶部有多远.
  2. 将按钮与超级视图的中心对齐.

对于 button1,您将需要...

<块引用>

  1. 如何从顶部向下.
  2. 离左边多远.

对于地图...

<块引用>

  1. 从底部、左侧和右侧开始为零.(这是三个独立的约束)
  2. button1 和地图顶部之间的间距是多少.

Here is design of my storyboard:

And here is output:

Why this button is not located in its correct location?

解决方案

This is a common question on Stack Overflow. You need to add auto layout constraints to the button. It doesn't know if you mean "in the centre" or "300 points from the left". You can add them by selecting the button and tapping the button with the square on it in the bottom right of the editor.

These are the buttons.

The buttons are...

  1. Align views. Either multiple views or along a single view with its superview.
  2. Add constraints to a specific view. Left, Top, Height, Width, etc...
  3. Auto constraints. Update frames to constraints. Etc...
  4. Resizing options.

You need to add constraints to ALL of the views in your app.

So, on button2 you will need to tell it...

  1. How far down from the top.
  2. Align the button to the centre of the superview.

For button1 you will need...

  1. How for down from the top.
  2. How far in from the left.

For the map...

  1. Zero from the bottom, left, and right. (That's three separate constraints)
  2. How much spacing between button1 and the top of the map.

这篇关于为什么故事板中的按钮未位于 ios8 中的适当位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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