如何找到崩溃约束?
有时候,我不断收到这样的错误,这些 - 没有任何提示到的TextView或按钮是指:如何找到崩溃约束?
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.
有没有一种方法,以确定在导致崩溃的代码的限制?
文本:
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x11d748d0 V:[UITextView:0xc1bb000(65)]>
遗憾的是没有太大的帮助,因为我没有任何想法,这约束,这是在代码
你喜欢这个阅读:
<NSLayoutConstraint:0x11d748d0 V: [UITextView:0xc1bb000(65)]>
^ Constraint type^Address ^Axis ^Description in VFL
(of constraint)
所以这是一个约束,迫使textview要高65分。在那里,你也有一个约束牵制这个文本视图,从它的父的顶部边缘134点:
<NSLayoutConstraint:0xa1980d0 V:|-(134)-[UITextView:0xc1bb000] (Names: '|':UIView:0xa1afba0)>
和约束牵制文本视图的Y中心按钮的Y中心:
<NSLayoutConstraint:0xa199ed0 UITextView:0xc1bb000.centerY == UIButton:0x11d71cf0.centerY>
和约束牵制按钮本身到一个特定的垂直位置:
<NSLayoutConstraint:0xa199e50 V:[UIButton:0x11d79e70]-(61)-[UIButton:0x11d71cf0]>
很可能是你不希望所有这些限制。这里有两个约束试图垂直放置文本视图(基于按钮,并且基于超级视图顶部的绝对间距)。
在您的应用程序中的某个位置,您必须有一个带有文本字段和两个按钮的视图。如果你打破了所有的例外情况,你可以注销日志中给出的各种地址,并且如果你不确定,找出超级浏览等等,但是希望你能从中解决这个问题。
有时是有帮助的日志复制到一个文本编辑器,找到/文字代替地址,以便更容易阅读。
非常感谢您的详细解释。我也只是把一个像NSLog(@“ok_btnTV%p”,_ ok_btnTV); 现在在我的viewDidAppear找到有问题的视图。现在花了不到10秒的时间才发现问题! - 这个“超级先进的用户界面生成器”有什么古老的方式来找到这样的问题......非常感谢! – user387184 2013-04-08 09:20:20
可能重复的[无法同时满足约束 - 没有约束到位](http://*.com/questions/14327145/unable-to-simultaneously-satisfy-constraints-no-constraints-in-place) - 在阅读这些日志时有帮助 – jrturton 2013-04-08 09:05:20