我無法在任何地方找到類似的問題,所以這是我的第一篇文章:我正在爲iPhone開發一個swift 2項目。我已經發明瞭一種「設置」屏幕具有嵌入堆的觀點:棧視圖中的自動約束違規,Swift 2,iOS 9.3,XCode 7
Layout showing bounds boxes and constraints
所以,還有一個主要的「垂直的」堆棧具有兩個子視圖,等距間隔的視圖:最上面的一個對應於調色板設置,用以下元件:
- 窗口的主標籤(「顏色方案」)
- 改變色調(色調),其中名稱的標籤(「色調」)的滑塊
- 開關以切換顏色/ B & W,與名稱標籤(「顏色」)
- A鈕單色調色板與「彩虹」調色板開關,與名稱標籤(「彩虹」)
- 9子視圖,一個用於每個調色板顏色 的水平疊層視圖
底部視圖是天氣視圖設置,並沒有任何問題。
主要堆棧視圖設置爲從縱向改變爲橫向時,從「垂直」更改爲「水平」:
Landscape orientation layout, showing all bounds boxes and constraints
故事板編輯器顯示沒有約束錯誤任何在任一方向(全部以藍色顯示),但在運行時,在模擬器中運行時,將設置屏幕方向更改爲橫向會生成多個「無法滿足約束」的錯誤,但屏幕顯示和表現完美。
奇怪的是,約束錯誤消息重複幾次,每次嘗試通過打破第二個堆棧視圖內的約束來恢復! (這些應該由堆棧視圖本身自動處理)。特別是,該系統試圖打破多個「等底」限制,將不同的嵌入子視圖對的底部設置爲相等的值。也就是說,第二個堆棧視圖中的九個子視圖應該有相同級別的底部邊界(這是由堆棧視圖本身強加的,所以我不能在我的程序中修改它)。系統每次嘗試時都會失敗,因此會向控制檯輸出新錯誤,系統會嘗試在堆棧視圖中打破另一個「底部底部」約束,並出現新的故障。
這會持續幾次(從5到8次),直到它通過試圖打破主標籤(「色彩方案」)垂直尺寸約束來解決。鑑於這個最終結果,我改變了主標籤垂直尺寸的壓縮優先級,但我仍然收到錯誤。這裏是一個控制檯轉儲:
2016-04-22 10:06:14.061 Just Now[9468:534833] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
"<_UILayoutSupportConstraint:0x7fa918c200e0 V:[_UILayoutGuide:0x7fa91f55acf0(44)]>",
"<_UILayoutSupportConstraint:0x7fa91f582a20 V:|-(0)-[_UILayoutGuide:0x7fa91f55acf0] (Names: '|':UIView:0x7fa91f53a530)>",
"<_UILayoutSupportConstraint:0x7fa91f5c65a0 V:[_UILayoutGuide:0x7fa91f5d2350(0)]>",
"<_UILayoutSupportConstraint:0x7fa918c11a20 _UILayoutGuide:0x7fa91f5d2350.bottom == UIView:0x7fa91f53a530.bottom>",
"<NSLayoutConstraint:0x7fa91f5d7bd0 V:[UISlider:0x7fa91f5d74e0(30)]>",
"<NSLayoutConstraint:0x7fa91f5c5ef0 V:[UILabel:0x7fa91f5c5c90'Color Scheme'(32)]>",
"<NSLayoutConstraint:0x7fa91f5d49d0 V:[UISwitch:0x7fa91f5d4810(31)]>",
"<NSLayoutConstraint:0x7fa91f53e850 V:[UILabel:0x7fa91f511840'Hue'(21)]>",
"<NSLayoutConstraint:0x7fa91f539a00 V:|-(8)-[UILabel:0x7fa91f5c5c90'Color Scheme'] (Names: '|':UIView:0x7fa91f5c5b00)>",
"<NSLayoutConstraint:0x7fa91f539af0 V:[UILabel:0x7fa91f5c5c90'Color Scheme']-(5)-[UILabel:0x7fa91f511840'Hue']>",
"<NSLayoutConstraint:0x7fa91f539b40 V:[UILabel:0x7fa91f511840'Hue']-(8)-[UISlider:0x7fa91f5d74e0]>",
"<NSLayoutConstraint:0x7fa91f539dc0 V:[UISwitch:0x7fa91f5d4810]-(19)-[UIStackView:0x7fa91f5c6650]>",
"<NSLayoutConstraint:0x7fa91f539e10 V:[UIStackView:0x7fa91f5c6650]-(8)-| (Names: '|':UIView:0x7fa91f5c5b00)>",
"<NSLayoutConstraint:0x7fa91f539f50 V:[UISlider:0x7fa91f5d74e0]-(37)-[UISwitch:0x7fa91f5d4810]>",
"<NSLayoutConstraint:0x7fa91f582f10 V:[_UILayoutGuide:0x7fa91f55acf0]-(0)-[UIStackView:0x7fa91f53a6a0]>",
"<NSLayoutConstraint:0x7fa91f582f60 V:[UIStackView:0x7fa91f53a6a0]-(0)-[_UILayoutGuide:0x7fa91f5d2350]>",
"<NSLayoutConstraint:0x7fa91f41c650 'UISV-alignment' UIView:0x7fa91f5c5850.bottom == UIView:0x7fa91f5c67e0.bottom>",
"<NSLayoutConstraint:0x7fa91f417010 'UISV-alignment' UIView:0x7fa91f5c5850.top == UIView:0x7fa91f5c67e0.top>",
"<NSLayoutConstraint:0x7fa91f434df0 'UISV-canvas-connection' UIStackView:0x7fa91f5c6650.top == UIView:0x7fa91f5c5850.top>",
"<NSLayoutConstraint:0x7fa91f40dad0 'UISV-canvas-connection' V:[UIView:0x7fa91f5c5850]-(0)-| (Names: '|':UIStackView:0x7fa91f5c6650)>",
"<NSLayoutConstraint:0x7fa91ffc1160 'UISV-canvas-connection' UIStackView:0x7fa91f53a6a0.top == UIView:0x7fa91f5c5b00.top>",
"<NSLayoutConstraint:0x7fa9228831e0 'UISV-canvas-connection' V:[UIView:0x7fa91f53a830]-(0)-| (Names: '|':UIStackView:0x7fa91f53a6a0)>",
"<NSLayoutConstraint:0x7fa921301830 'UISV-fill-equally' UIView:0x7fa91f53a830.height == UIView:0x7fa91f5c5b00.height>",
"<NSLayoutConstraint:0x7fa91ffc15b0 'UISV-spacing' V:[UIView:0x7fa91f5c5b00]-(0)-[UIView:0x7fa91f53a830]>",
"<NSLayoutConstraint:0x7fa91ffb8540 'UIView-Encapsulated-Layout-Height' V:[UIView:0x7fa91f53a530(414)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7fa91f41c650 'UISV-alignment' UIView:0x7fa91f5c5850.bottom == UIView:0x7fa91f5c67e0.bottom>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2016-04-22 10:06:14.063 Just Now[9468:534833] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
"<_UILayoutSupportConstraint:0x7fa918c200e0 V:[_UILayoutGuide:0x7fa91f55acf0(44)]>",
"<_UILayoutSupportConstraint:0x7fa91f582a20 V:|-(0)-[_UILayoutGuide:0x7fa91f55acf0] (Names: '|':UIView:0x7fa91f53a530)>",
"<_UILayoutSupportConstraint:0x7fa91f5c65a0 V:[_UILayoutGuide:0x7fa91f5d2350(0)]>",
"<_UILayoutSupportConstraint:0x7fa918c11a20 _UILayoutGuide:0x7fa91f5d2350.bottom == UIView:0x7fa91f53a530.bottom>",
"<NSLayoutConstraint:0x7fa91f5d7bd0 V:[UISlider:0x7fa91f5d74e0(30)]>",
"<NSLayoutConstraint:0x7fa91f5c5ef0 V:[UILabel:0x7fa91f5c5c90'Color Scheme'(32)]>",
"<NSLayoutConstraint:0x7fa91f5d49d0 V:[UISwitch:0x7fa91f5d4810(31)]>",
"<NSLayoutConstraint:0x7fa91f53e850 V:[UILabel:0x7fa91f511840'Hue'(21)]>",
"<NSLayoutConstraint:0x7fa91f539a00 V:|-(8)-[UILabel:0x7fa91f5c5c90'Color Scheme'] (Names: '|':UIView:0x7fa91f5c5b00)>",
"<NSLayoutConstraint:0x7fa91f539af0 V:[UILabel:0x7fa91f5c5c90'Color Scheme']-(5)-[UILabel:0x7fa91f511840'Hue']>",
"<NSLayoutConstraint:0x7fa91f539b40 V:[UILabel:0x7fa91f511840'Hue']-(8)-[UISlider:0x7fa91f5d74e0]>",
"<NSLayoutConstraint:0x7fa91f539dc0 V:[UISwitch:0x7fa91f5d4810]-(19)-[UIStackView:0x7fa91f5c6650]>",
"<NSLayoutConstraint:0x7fa91f539e10 V:[UIStackView:0x7fa91f5c6650]-(8)-| (Names: '|':UIView:0x7fa91f5c5b00)>",
"<NSLayoutConstraint:0x7fa91f539f50 V:[UISlider:0x7fa91f5d74e0]-(37)-[UISwitch:0x7fa91f5d4810]>",
"<NSLayoutConstraint:0x7fa91f582f10 V:[_UILayoutGuide:0x7fa91f55acf0]-(0)-[UIStackView:0x7fa91f53a6a0]>",
"<NSLayoutConstraint:0x7fa91f582f60 V:[UIStackView:0x7fa91f53a6a0]-(0)-[_UILayoutGuide:0x7fa91f5d2350]>",
"<NSLayoutConstraint:0x7fa921340700 'UISV-alignment' UIView:0x7fa91f5c5850.bottom == UIView:0x7fa91f5c6970.bottom>",
"<NSLayoutConstraint:0x7fa91f417120 'UISV-alignment' UIView:0x7fa91f5c5850.top == UIView:0x7fa91f5c6970.top>",
"<NSLayoutConstraint:0x7fa91f434df0 'UISV-canvas-connection' UIStackView:0x7fa91f5c6650.top == UIView:0x7fa91f5c5850.top>",
"<NSLayoutConstraint:0x7fa91f40dad0 'UISV-canvas-connection' V:[UIView:0x7fa91f5c5850]-(0)-| (Names: '|':UIStackView:0x7fa91f5c6650)>",
"<NSLayoutConstraint:0x7fa91ffc1160 'UISV-canvas-connection' UIStackView:0x7fa91f53a6a0.top == UIView:0x7fa91f5c5b00.top>",
"<NSLayoutConstraint:0x7fa9228831e0 'UISV-canvas-connection' V:[UIView:0x7fa91f53a830]-(0)-| (Names: '|':UIStackView:0x7fa91f53a6a0)>",
"<NSLayoutConstraint:0x7fa921301830 'UISV-fill-equally' UIView:0x7fa91f53a830.height == UIView:0x7fa91f5c5b00.height>",
"<NSLayoutConstraint:0x7fa91ffc15b0 'UISV-spacing' V:[UIView:0x7fa91f5c5b00]-(0)-[UIView:0x7fa91f53a830]>",
"<NSLayoutConstraint:0x7fa91ffb8540 'UIView-Encapsulated-Layout-Height' V:[UIView:0x7fa91f53a530(414)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7fa921340700 'UISV-alignment' UIView:0x7fa91f5c5850.bottom == UIView:0x7fa91f5c6970.bottom>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2016-04-22 10:06:14.064 Just Now[9468:534833] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
"<_UILayoutSupportConstraint:0x7fa918c200e0 V:[_UILayoutGuide:0x7fa91f55acf0(44)]>",
"<_UILayoutSupportConstraint:0x7fa91f582a20 V:|-(0)-[_UILayoutGuide:0x7fa91f55acf0] (Names: '|':UIView:0x7fa91f53a530)>",
"<_UILayoutSupportConstraint:0x7fa91f5c65a0 V:[_UILayoutGuide:0x7fa91f5d2350(0)]>",
"<_UILayoutSupportConstraint:0x7fa918c11a20 _UILayoutGuide:0x7fa91f5d2350.bottom == UIView:0x7fa91f53a530.bottom>",
"<NSLayoutConstraint:0x7fa91f5d7bd0 V:[UISlider:0x7fa91f5d74e0(30)]>",
"<NSLayoutConstraint:0x7fa91f5c5ef0 V:[UILabel:0x7fa91f5c5c90'Color Scheme'(32)]>",
"<NSLayoutConstraint:0x7fa91f5d49d0 V:[UISwitch:0x7fa91f5d4810(31)]>",
"<NSLayoutConstraint:0x7fa91f53e850 V:[UILabel:0x7fa91f511840'Hue'(21)]>",
"<NSLayoutConstraint:0x7fa91f539a00 V:|-(8)-[UILabel:0x7fa91f5c5c90'Color Scheme'] (Names: '|':UIView:0x7fa91f5c5b00)>",
"<NSLayoutConstraint:0x7fa91f539af0 V:[UILabel:0x7fa91f5c5c90'Color Scheme']-(5)-[UILabel:0x7fa91f511840'Hue']>",
"<NSLayoutConstraint:0x7fa91f539b40 V:[UILabel:0x7fa91f511840'Hue']-(8)-[UISlider:0x7fa91f5d74e0]>",
"<NSLayoutConstraint:0x7fa91f539dc0 V:[UISwitch:0x7fa91f5d4810]-(19)-[UIStackView:0x7fa91f5c6650]>",
"<NSLayoutConstraint:0x7fa91f539e10 V:[UIStackView:0x7fa91f5c6650]-(8)-| (Names: '|':UIView:0x7fa91f5c5b00)>",
"<NSLayoutConstraint:0x7fa91f539f50 V:[UISlider:0x7fa91f5d74e0]-(37)-[UISwitch:0x7fa91f5d4810]>",
"<NSLayoutConstraint:0x7fa91f582f10 V:[_UILayoutGuide:0x7fa91f55acf0]-(0)-[UIStackView:0x7fa91f53a6a0]>",
"<NSLayoutConstraint:0x7fa91f582f60 V:[UIStackView:0x7fa91f53a6a0]-(0)-[_UILayoutGuide:0x7fa91f5d2350]>",
"<NSLayoutConstraint:0x7fa921340870 'UISV-alignment' UIView:0x7fa91f5c5850.bottom == UIView:0x7fa91f5c6b00.bottom>",
"<NSLayoutConstraint:0x7fa91f4171f0 'UISV-alignment' UIView:0x7fa91f5c5850.top == UIView:0x7fa91f5c6b00.top>",
"<NSLayoutConstraint:0x7fa91f434df0 'UISV-canvas-connection' UIStackView:0x7fa91f5c6650.top == UIView:0x7fa91f5c5850.top>",
"<NSLayoutConstraint:0x7fa91f40dad0 'UISV-canvas-connection' V:[UIView:0x7fa91f5c5850]-(0)-| (Names: '|':UIStackView:0x7fa91f5c6650)>",
"<NSLayoutConstraint:0x7fa91ffc1160 'UISV-canvas-connection' UIStackView:0x7fa91f53a6a0.top == UIView:0x7fa91f5c5b00.top>",
"<NSLayoutConstraint:0x7fa9228831e0 'UISV-canvas-connection' V:[UIView:0x7fa91f53a830]-(0)-| (Names: '|':UIStackView:0x7fa91f53a6a0)>",
"<NSLayoutConstraint:0x7fa921301830 'UISV-fill-equally' UIView:0x7fa91f53a830.height == UIView:0x7fa91f5c5b00.height>",
"<NSLayoutConstraint:0x7fa91ffc15b0 'UISV-spacing' V:[UIView:0x7fa91f5c5b00]-(0)-[UIView:0x7fa91f53a830]>",
"<NSLayoutConstraint:0x7fa91ffb8540 'UIView-Encapsulated-Layout-Height' V:[UIView:0x7fa91f53a530(414)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7fa921340870 'UISV-alignment' UIView:0x7fa91f5c5850.bottom == UIView:0x7fa91f5c6b00.bottom>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2016-04-22 10:06:14.065 Just Now[9468:534833] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
"<_UILayoutSupportConstraint:0x7fa918c200e0 V:[_UILayoutGuide:0x7fa91f55acf0(44)]>",
"<_UILayoutSupportConstraint:0x7fa91f582a20 V:|-(0)-[_UILayoutGuide:0x7fa91f55acf0] (Names: '|':UIView:0x7fa91f53a530)>",
"<_UILayoutSupportConstraint:0x7fa91f5c65a0 V:[_UILayoutGuide:0x7fa91f5d2350(0)]>",
"<_UILayoutSupportConstraint:0x7fa918c11a20 _UILayoutGuide:0x7fa91f5d2350.bottom == UIView:0x7fa91f53a530.bottom>",
"<NSLayoutConstraint:0x7fa91f5d7bd0 V:[UISlider:0x7fa91f5d74e0(30)]>",
"<NSLayoutConstraint:0x7fa91f5c5ef0 V:[UILabel:0x7fa91f5c5c90'Color Scheme'(32)]>",
"<NSLayoutConstraint:0x7fa91f5d49d0 V:[UISwitch:0x7fa91f5d4810(31)]>",
"<NSLayoutConstraint:0x7fa91f53e850 V:[UILabel:0x7fa91f511840'Hue'(21)]>",
"<NSLayoutConstraint:0x7fa91f539a00 V:|-(8)-[UILabel:0x7fa91f5c5c90'Color Scheme'] (Names: '|':UIView:0x7fa91f5c5b00)>",
"<NSLayoutConstraint:0x7fa91f539af0 V:[UILabel:0x7fa91f5c5c90'Color Scheme']-(5)-[UILabel:0x7fa91f511840'Hue']>",
"<NSLayoutConstraint:0x7fa91f539b40 V:[UILabel:0x7fa91f511840'Hue']-(8)-[UISlider:0x7fa91f5d74e0]>",
"<NSLayoutConstraint:0x7fa91f539dc0 V:[UISwitch:0x7fa91f5d4810]-(19)-[UIStackView:0x7fa91f5c6650]>",
"<NSLayoutConstraint:0x7fa91f539e10 V:[UIStackView:0x7fa91f5c6650]-(8)-| (Names: '|':UIView:0x7fa91f5c5b00)>",
"<NSLayoutConstraint:0x7fa91f539f50 V:[UISlider:0x7fa91f5d74e0]-(37)-[UISwitch:0x7fa91f5d4810]>",
"<NSLayoutConstraint:0x7fa91f582f10 V:[_UILayoutGuide:0x7fa91f55acf0]-(0)-[UIStackView:0x7fa91f53a6a0]>",
"<NSLayoutConstraint:0x7fa91f582f60 V:[UIStackView:0x7fa91f53a6a0]-(0)-[_UILayoutGuide:0x7fa91f5d2350]>",
"<NSLayoutConstraint:0x7fa91ffc1160 'UISV-canvas-connection' UIStackView:0x7fa91f53a6a0.top == UIView:0x7fa91f5c5b00.top>",
"<NSLayoutConstraint:0x7fa9228831e0 'UISV-canvas-connection' V:[UIView:0x7fa91f53a830]-(0)-| (Names: '|':UIStackView:0x7fa91f53a6a0)>",
"<NSLayoutConstraint:0x7fa921301830 'UISV-fill-equally' UIView:0x7fa91f53a830.height == UIView:0x7fa91f5c5b00.height>",
"<NSLayoutConstraint:0x7fa91ffc15b0 'UISV-spacing' V:[UIView:0x7fa91f5c5b00]-(0)-[UIView:0x7fa91f53a830]>",
"<NSLayoutConstraint:0x7fa91ffb8540 'UIView-Encapsulated-Layout-Height' V:[UIView:0x7fa91f53a530(414)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7fa91f5c5ef0 V:[UILabel:0x7fa91f5c5c90'Color Scheme'(32)]>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
我試圖走動的東西,但我在故事板編輯器沒有錯誤和旋轉屏幕,當運行時錯誤繼續下去。它試圖在堆棧視圖中打破自動約束的事實讓我覺得這可能是一個錯誤。無論錯誤如何,程序都能正常工作,看起來應該如此,所以我不知所措。
任何幫助將不勝感激。提前致謝!