堆栈视图中的uilabel字段的Autolayout问题

时间:2018-03-22 21:03:27

标签: swift xcode9 ios-autolayout

我希望有一个包含3行和2列的小网格。第一列的编号为1..3,即第二列。在水平StackView中使用两个UILabel字段创建每一行,所有这些字段都包含在垂直StackView中。这个外部StackView对其超级视图具有前导,尾随,顶部和底部约束,以使其保持原位。

这是来自Xcode 9的视图控制器场景

enter image description here

外部StackView'步骤'有:

Axis = Vertical
Alignment = Fill
Distribution = Fill Proportionally

每个StackViews行都有:

Axis = Horizontal
Alignment = Center
Distribution = Fill Proportionally

如果有两个问题: a)XCode的StoryBoard没有显示任何东西,即,我看到一个大的白色空ViewController。单击检查器中的组件,我可以看到哪些内容'东西'应该显示但是,我看不到任何文字,娜娜。 b)当我运行“应用程序”时它实际上显示了文本应该在哪里,但是,我在调试器输出中得到以下内容:

2018-03-22 13:41:33.423864-0700 stackview_test[35635:4781389] [LayoutConstraints] 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. 
(
    "<NSLayoutConstraint:0x60c000089d80 'fittingSizeHTarget' UIStackView:0x7feb69614b00.width == 0   (active)>",
    "<NSLayoutConstraint:0x60c00008f050 'UISV-canvas-connection' UIStackView:0x7feb69614b00.leading == UILabel:0x7feb69614d00'2'.leading   (active)>",
    "<NSLayoutConstraint:0x60c00008f190 'UISV-canvas-connection' H:[UILabel:0x7feb69614fe0'Lorem ipsum dolor sit ame...']-(0)-|   (active, names: '|':UIStackView:0x7feb69614b00 )>",
    "<NSLayoutConstraint:0x60c00008f910 'UISV-spacing' H:[UILabel:0x7feb69614d00'2']-(20)-[UILabel:0x7feb69614fe0'Lorem ipsum dolor sit ame...']   (active)>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x60c00008f910 'UISV-spacing' H:[UILabel:0x7feb69614d00'2']-(20)-[UILabel:0x7feb69614fe0'Lorem ipsum dolor sit ame...']   (active)>

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.
2018-03-22 13:41:33.428202-0700 stackview_test[35635:4781389] [LayoutConstraints] 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. 
(
    "<NSLayoutConstraint:0x60800008da20 'fittingSizeHTarget' UIStackView:0x7feb696156e0.width == 0   (active)>",
    "<NSLayoutConstraint:0x60c0000903b0 'UISV-canvas-connection' UIStackView:0x7feb696156e0.leading == UILabel:0x7feb69615de0'3'.leading   (active)>",
    "<NSLayoutConstraint:0x60c000090450 'UISV-canvas-connection' H:[UILabel:0x7feb696160c0'At vero eos et accusamus ...']-(0)-|   (active, names: '|':UIStackView:0x7feb696156e0 )>",
    "<NSLayoutConstraint:0x60c000090770 'UISV-spacing' H:[UILabel:0x7feb69615de0'3']-(20)-[UILabel:0x7feb696160c0'At vero eos et accusamus ...']   (active)>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x60c000090770 'UISV-spacing' H:[UILabel:0x7feb69615de0'3']-(20)-[UILabel:0x7feb696160c0'At vero eos et accusamus ...']   (active)>

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.

知道发生了什么事吗?我一定很感激你的见解。

0 个答案:

没有答案