【发布时间】:2013-07-24 10:30:20
【问题描述】:
我想要达到的目标:
Custom View 1
aligned at the top
fixed height = 20px
width = window width
Horizontal Split View
just below the custom view
width = window width
height = as large as possible
Custom View 2
aligned at the bottom
fixed height = 20px
width = window width
这是一个非常简单的布局:窗口顶部和底部有一个页眉和一个页脚,中间有一个拆分视图,左侧和右侧的一些内容应随窗口调整大小。但是,Apple 设计的自动布局管理器非常糟糕,我似乎无法让它工作。 (我已经摸索了大约三个小时!)
问题是:一旦我给自定义视图一个固定的高度,窗口高度就会被锁定,我不能再垂直调整它的大小。我正在尝试通过以下限制来做到这一点:
Custom View 1
Constraints
height = 20px
Custom View 2
height = 20px
Constraints
Leading horiz space from Custom View 1 to Superview = 0
Leading horiz space from Custom View 2 to Superview = 0
Leading horiz space from Split View to Superview = 0
Trailing horiz space from Custom View 1 to Superview = 0
Trailing horiz space from Custom View 2 to Superview = 0
Trailing horiz space from Split View to Superview = 0
Top vert space between Custom View 1 and Superview = 0
Vert space between Custom View 1 and Split View = 0
Vert space between Custom View 2 and Split View = 0
Bottom vert space between Custom View 2 and Superview = 0
Top vert space between Custom View 2 and Superview = 344px (!)
最后一行是Xcode添加的,我删不掉。当然,这是负责固定垂直布局的。我怎样才能摆脱它???
【问题讨论】:
标签: xcode constraints autolayout