gpt4 book ai didi

ios - Xcode swift : Why is it breaking my Constraints?

转载 作者:行者123 更新时间:2023-11-28 15:23:27 25 4
gpt4 key购买 nike

我刚开始学习 Swift Developing iOS Apps (Swift)教程。我正在创建此自定义评级控件,但每次我运行该应用程序时都会发送以下错误:

2017-08-09 15:49:41.894597+0200 FoodTracker[5051:2273797] [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:0x17409af90 UIButton:0x100c12d90.width == 44 (active)>",
"<NSLayoutConstraint:0x17009c160 'UISV-canvas-connection' FoodTracker.RatingControl:0x100c02400.leading == UIButton:0x100c12d90.leading (active)>",
"<NSLayoutConstraint:0x17009c200 'UISV-canvas-connection' H:[UIButton:0x100c12d90]-(0)-| (active, names: '|':FoodTracker.RatingControl:0x100c02400 )>",
"<NSLayoutConstraint:0x17009bee0 'UIView-Encapsulated-Layout-Width' FoodTracker.RatingControl:0x100c02400.width == 343 (active)>"
)

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x17409af90 UIButton:0x100c12d90.width == 44 (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.
2017-08-09 15:49:41.895770+0200 FoodTracker[5051:2273797] [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:0x17409af40 UIButton:0x100c12d90.height == 44 (active)>",
"<NSLayoutConstraint:0x17009c250 'UISV-canvas-connection' FoodTracker.RatingControl:0x100c02400.top == UIButton:0x100c12d90.top (active)>",
"<NSLayoutConstraint:0x17009c340 'UISV-canvas-connection' V:[UIButton:0x100c12d90]-(0)-| (active, names: '|':FoodTracker.RatingControl:0x100c02400 )>",
"<NSLayoutConstraint:0x17009bf30 'UIView-Encapsulated-Layout-Height' FoodTracker.RatingControl:0x100c02400.height == 50 (active)>"
)

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x17409af40 UIButton:0x100c12d90.height == 44 (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.

我为 Button width == 44 和 Button height == 44 设置了约束,但没有设置其他约束。我按照教程中的描述做了所有事情,但不知道为什么它不起作用。我检查了我能找到的所有约束,但我不确定是否全部,因为我对 Xcode 不是很有经验。有没有人知道如何解决问题?

This is how it should look like: Apples Result But this is how it looks:My Result (Only The Red Area is important)

最佳答案

我也遇到过类似的问题。解决方案很简单,如图所示,将水平堆栈 View 移动(拖放)到垂直堆栈 View 下,如图所示。

关于ios - Xcode swift : Why is it breaking my Constraints?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45593826/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com