gpt4 book ai didi

ios - 对 Segment 使用约束时发生冲突

转载 作者:行者123 更新时间:2023-11-29 02:20:25 27 4
gpt4 key购买 nike

因此,当遇到此问题时,我将片段添加到 Storyboard中并使用“添加缺失约束”。

App Screenshot

这个非常复杂的(对我来说)错误:

2015-01-29 22:29:16.151 MafiaPhone[45162:1236769] 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. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<_UILayoutSupportConstraint:0x7f9e397572b0 V:[_UILayoutGuide:0x7f9e39627f00(64)]>",
"<_UILayoutSupportConstraint:0x7f9e3975cbb0 V:|-(0)-[_UILayoutGuide:0x7f9e39627f00] (Names: '|':UIView:0x7f9e39627e30 )>",
"<_UILayoutSupportConstraint:0x7f9e39748a80 V:[_UILayoutGuide:0x7f9e396286b0(0)]>",
"<_UILayoutSupportConstraint:0x7f9e3972bc70 _UILayoutGuide:0x7f9e396286b0.bottom == UIView:0x7f9e39627e30.bottom>",
"<NSLayoutConstraint:0x7f9e39732f20 V:[_UILayoutGuide:0x7f9e39627f00]-(106)-[UITextField:0x7f9e39628e00]>",
"<NSLayoutConstraint:0x7f9e3974bb80 V:[UILabel:0x7f9e397528a0'Role Name']-(29)-[UILabel:0x7f9e3970c3e0'Side']>",
"<NSLayoutConstraint:0x7f9e3971d360 UILabel:0x7f9e3970c3e0'Side'.lastBaseline == UISegmentedControl:0x7f9e39749690.firstBaseline>",
"<NSLayoutConstraint:0x7f9e39747ac0 UILabel:0x7f9e397528a0'Role Name'.lastBaseline == UITextField:0x7f9e39628e00.firstBaseline>",
"<NSLayoutConstraint:0x7f9e39747b10 V:[UISegmentedControl:0x7f9e39749690]-(37)-[UIButton:0x7f9e39737e20'Add']>",
"<NSLayoutConstraint:0x7f9e39754070 UIButton:0x7f9e39737e20'Add'.centerY == UIView:0x7f9e39627e30.centerY>",
"<NSLayoutConstraint:0x7f9e397540c0 V:[UIButton:0x7f9e39737e20'Add']-(241)-[_UILayoutGuide:0x7f9e396286b0]>",
"<NSLayoutConstraint:0x7f9e39754160 UISegmentedControl:0x7f9e39749690.lastBaseline == UILabel:0x7f9e3970c3e0'Side'.firstBaseline>",
"<NSLayoutConstraint:0x7f9e39754200 UISegmentedControl:0x7f9e39749690.lastBaseline == UILabel:0x7f9e3970c3e0'Side'.lastBaseline>",
"<NSLayoutConstraint:0x7f9e39754250 V:[UISegmentedControl:0x7f9e39749690(28)]>",
"<NSAutoresizingMaskLayoutConstraint:0x7f9e39521a20 h=--& v=--& UISegment:0x7f9e3972eef0.midY == + 14.5>",
"<NSLayoutConstraint:0x7f9e3951a7a0 UISegmentLabel:0x7f9e39732a30'Second'.centerY == UISegment:0x7f9e3972eef0.centerY>",
"<NSLayoutConstraint:0x7f9e3954b6d0 V:|-(6)-[_UIBaselineLayoutStrut:0x7f9e39760330] (Names: '|':UITextField:0x7f9e39628e00 )>"
)

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7f9e3951a7a0 UISegmentLabel:0x7f9e39732a30'Second'.centerY == UISegment:0x7f9e3972eef0.centerY>

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.

片段是唯一出现位置错误的部分。这是约束选项。

Constrain Option

我的问题是:1. 错误是什么意思?2.如何解决这个问题?3. 使用“添加缺失的约束”是否正确(到目前为止,这是我为使运行 View 看起来与 Storyboard View 完全相同而做的唯一事情)?为什么?

感谢您阅读整篇长文。希望您能帮助我解决这个令人沮丧的错误!

最佳答案

看来您的系统有太多限制。 “添加”按钮有一个 centerY 约束,以及将其固定到其上方 View 的约束,以及底部布局指南。很难知道你想要哪些约束。我会删除“添加”按钮和底部布局指南之间的一个,以及文本字段和导航栏之间的一个。

您确实不应该通过使用“添加缺失的约束”来对一组复杂的 View 设置约束。明确添加您需要的内容。如果您不知道如何操作,请观看 2012 年 WWDC 上有关自动布局的视频。

关于ios - 对 Segment 使用约束时发生冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28218577/

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