IOS xcode 6故事板自动布局

时间:2015-09-04 05:56:09

标签: ios xcode xcode6 autolayout

我需要在我的iPhone应用中创建一个简单的登录屏幕,并且发现很难调整TextField以使用容器考虑' Trailing space to Container'

我已将TextFieldsLabels放在滚动视图中并指定了以下约束

用户名标签

- "Leading Space to Container"
- "Top Space to Container"
- "Horizontal Spacing to the 'Username' TextField"

用户名TextField

- "Horizontal spacing to 'Username' Label"
- "Top Spacing to Container"
- "Trailing Space to Contaner"

我的用户界面如下

enter image description here

获取有关宽度的以下警告但如果我将其设置为471,因为它表示它超出滚动视图且无法访问

enter image description here

如果忽略警告并在模拟器中运行,textFiled不会在容器中采用填充宽度来保持' Trailing Space to Contaner' ...

当我跑步时,我得到的就是这个:

enter image description here

我应该怎么做才能在容器中保持TextField全长(保持Trailing Space to Container

2 个答案:

答案 0 :(得分:2)

我已经提出了这个观点,不要将所有内容直接保存到scrollview中,在scrollview中放置一个新视图,并使用scrollview应用新的约束等宽度来解决所有问题。我可以给你代码也是如果你无法应用它们。

运气好 enter image description here

答案 1 :(得分:1)

在UIScrollview上使用UIView是一个很好的做法。现在要设置随屏幕大小而变化的文本字段的正确宽度,您需要设置Top,水平空格和标签,尾随空格。如果有任何错误的视图警告,您也可以设置其宽高比。