我想達到的目標:的Xcode自動佈局:不能調整窗口
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
這是一個非常簡單的佈局:一個標題,並在窗口的頂部和底部的頁腳,在拆分視圖之間的一些內容應左右調整窗口大小。但是,蘋果公司很自動地設計了自動佈局管理器,我似乎無法得到這個工作。 (我已經摸索了大約三個小時吧!)
問題是:只要我給定製視圖一個固定的高度,窗口高度被鎖定,我不能再垂直調整它。我試圖做以下約束:
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中添加約束,但是選中「placeholder」這個框 - 這會在運行時刪除它,所以你的xib看起來不錯,但是約束不會在你的應用中修復。 – Jesse