我在任何地方都找不到类似的问题,所以这是我的第一篇文章:我正在为 iPhone 做一个 swift 2 项目。我设计了一个带有嵌入式堆栈视图的"设置"屏幕:
显示边界框和约束的布局
因此,有一个主要的"垂直"堆栈视图,其中包含两个间隔相等的子视图:顶部对应于调色板设置,具有以下元素:
- 窗口的主标签("配色方案")
- 用于更改色调(色调)的滑块,带有名称标签("色调")
- 切换颜色/黑白,带有名称标签("颜色") 切换单色调色板与"彩虹
- "调色板的开关,名称标签("彩虹")
- 具有 9 个子视图的水平堆栈视图,每个子视图对应一个调色板颜色
底部视图用于天气视图设置,没有任何问题。
主堆栈视图设置为在从纵向更改为横向时从"垂直"更改为"水平":
横向布局,显示所有边界框和约束
情节提要编辑器在任一方向上均未显示任何约束错误(全部显示为蓝色),但在运行时,在模拟器中运行时,将设置屏幕方向更改为横向会生成多个"无法满足约束"错误,尽管屏幕显示和行为完美。
奇怪的是,约束错误消息重复多次,每次都试图通过破坏第二个堆栈视图中的约束来恢复!(应该由堆栈视图本身自动处理)。特别是,系统正在尝试打破多个"相等底部"约束,将不同嵌入式子视图对的底部设置为相等的值。也就是说,第二个堆栈视图中的九个子视图应该具有同一级别的底部边界(这是由堆栈视图本身强加的,所以我无法在我的程序中修改它)。每次系统尝试此操作时,都会失败,因此会将新错误输出到控制台,并且系统会尝试破坏堆栈视图中的另一个"bottom == bottom"约束,并出现新的故障。
这种情况持续了几次(从 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.
我尝试过移动东西,但是在情节提要编辑器中没有收到任何错误,并且在旋转屏幕时运行时错误仍然存在。它试图打破堆栈视图中的自动约束这一事实使我认为这可能是一个错误。无论错误如何,该程序都可以正常工作并看起来像它应该的那样,所以我不知所措。
任何帮助将不胜感激。提前感谢!
好的。我想每个人都知道这一点,这就是为什么我没有得到任何答案......但是这个错误消失了,Xcode不再抱怨。如果它返回,我将发布后续内容。