有时我会不断收到这样的错误 - 没有任何暗示TextView或Button的含义:
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)
(
"<NSLayoutConstraint:0x11d748d0 V:[UITextView:0xc1bb000(65)]>",
"<NSLayoutConstraint:0x11d77620 V:[UIButton:0x11d71cf0(44)]>",
"<NSLayoutConstraint:0x11d7be30 V:[UIButton:0x11d79e70(43)]>",
"<NSLayoutConstraint:0xa1980d0 V:|-(134)-[UITextView:0xc1bb000] (Names: '|':UIView:0xa1afba0 )>",
"<NSLayoutConstraint:0xa199ed0 UITextView:0xc1bb000.centerY == UIButton:0x11d71cf0.centerY>",
"<NSLayoutConstraint:0xa199e50 V:[UIButton:0x11d79e70]-(61)-[UIButton:0x11d71cf0]>",
"<NSLayoutConstraint:0xa199cb0 V:|-(40)-[UIButton:0x11d79e70] (Names: '|':UIView:0xa1afba0 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x11d748d0 V:[UITextView:0xc1bb000(65)]>
Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
Run Code Online (Sandbox Code Playgroud)
有没有办法识别导致崩溃的代码中的约束?
文本:
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x11d748d0 V:[UITextView:0xc1bb000(65)]>
Run Code Online (Sandbox Code Playgroud)
遗憾的是没有多大帮助,因为我不知道这在代码中有哪些约束
你这样读他们:
<NSLayoutConstraint:0x11d748d0 V: [UITextView:0xc1bb000(65)]>
^ Constraint type ^ Address ^Axis ^Description in VFL
(of constraint)
Run Code Online (Sandbox Code Playgroud)
所以这是一个约束,迫使textview高达65分.在那里你还有一个约束将这个文本视图固定到其superview的顶部边缘134点:
<NSLayoutConstraint:0xa1980d0 V:|-(134)-[UITextView:0xc1bb000] (Names: '|':UIView:0xa1afba0 )>
Run Code Online (Sandbox Code Playgroud)
并且约束将文本视图的Y中心固定到按钮的Y中心:
<NSLayoutConstraint:0xa199ed0 UITextView:0xc1bb000.centerY == UIButton:0x11d71cf0.centerY>
Run Code Online (Sandbox Code Playgroud)
并且有一个约束将按钮固定到特定的垂直位置:
<NSLayoutConstraint:0xa199e50 V:[UIButton:0x11d79e70]-(61)-[UIButton:0x11d71cf0]>
Run Code Online (Sandbox Code Playgroud)
你很可能不想要所有这些限制.这里有两个约束,它们试图垂直定位文本视图(基于按钮,并基于超视图顶部的绝对间距).
在应用程序的某个位置,您必须拥有一个带有文本字段和两个按钮的视图.如果你打破所有例外,你可以注销日志中给出的各种地址,如果你不确定,可以找出超级视图等,但希望你能够从中解决这个问题.
有时将日志复制到文本编辑器并使用单词查找/替换地址以便于阅读更有帮助.
| 归档时间: |
|
| 查看次数: |
2297 次 |
| 最近记录: |