为什么在故事板按钮没有位于iOS8上合适的位置? [英] Why button in storyboard is not located in appropriate location in ios8?

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

问题描述

这是我的故事板设计的:

这里是输出:

为什么这个按钮并非位于其正确位置?


解决方案

这是对堆栈溢出一个共同的问题。你需要自动布局约束添加到按钮。它不知道,如果你在中心或从左边300点的意思。您可以通过选择按钮,并在编辑器的右下角就可以了方形轻点按钮进行添加。

这些按钮。

该按钮...


  1. 对齐意见。无论是多个视图或连同它的父的单一视图。

  2. 添加约束特定视图。左侧,顶部,高度,宽度等...

  3. 自动约束。更新框架制约。等等...

  4. 调整选项。

您需要添加约束所有的意见在您的应用程序。

因此​​,在按钮2 你需要告诉它...


  

      
  1. 如何从顶部往下远

  2.   
  3. 对齐按钮,将上海华中心。

  4.   

有关按钮1 您将需要...


  

      
  1. 如何从自上而下。

  2.   
  3. 多远从左侧。

  4.   

有关地图...


  

      
  1. 从零的底部,左,右。 (这是三个独立的限制)

  2.   
  3. 按钮1 之间多少间距和地图顶部。

  4.   

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天全站免登陆