无法同时满足约束条件,将尝试通过打破约束条件进行恢复

以下是我在调试区域中收到的错误消息。它运行正常,除了我收到此错误外,没有什么错。这会阻止苹果接受该应用程序吗?我如何解决它?


2012-07-26 01:58:18.621 Rolo[33597:11303] 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) 

(

    "<NSAutoresizingMaskLayoutConstraint:0x887d630 h=--& v=--& V:[UIButtonLabel:0x886ed80(19)]>",

    "<NSAutoresizingMaskLayoutConstraint:0x887d5f0 h=--& v=--& UIButtonLabel:0x886ed80.midY == + 37.5>",

    "<NSAutoresizingMaskLayoutConstraint:0x887b4b0 h=--& v=--& V:[UIButtonLabel:0x72bb9b0(19)]>",

    "<NSAutoresizingMaskLayoutConstraint:0x887b470 h=--& v=--& UIButtonLabel:0x72bb9b0.midY == - 0.5>",

    "<NSLayoutConstraint:0x72bf860 V:[UILabel:0x72bf7c0(17)]>",

    "<NSLayoutConstraint:0x72c2430 UILabel:0x72bfad0.top == UILabel:0x72bf7c0.top>",

    "<NSLayoutConstraint:0x72c2370 UILabel:0x72c0270.top == UILabel:0x72bfad0.top>",

    "<NSLayoutConstraint:0x72c22b0 V:[UILabel:0x72bf7c0]-(NSSpace(8))-[UIButton:0x886efe0]>",

    "<NSLayoutConstraint:0x72c15b0 V:[UILabel:0x72c0270]-(NSSpace(8))-[UIRoundedRectButton:0x72bbc10]>",

    "<NSLayoutConstraint:0x72c1570 UIRoundedRectButton:0x72bbc10.baseline == UIRoundedRectButton:0x7571170.baseline>",

    "<NSLayoutConstraint:0x72c21f0 UIRoundedRectButton:0x7571170.top == UIButton:0x886efe0.top>"

)


Will attempt to recover by breaking constraint 

<NSLayoutConstraint:0x72bf860 V:[UILabel:0x72bf7c0(17)]>


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.


慕妹3146593
浏览 2047回答 3
3回答

噜噜哒

我抛出了很多这样的异常,我找到解决它们的最快,最简单的方法是在异常中找到唯一的值,然后在情节提要源代码中搜索这些异常。这帮助我找到了导致问题的实际视图和约束(我在所有视图上使用了有意义的userLabel,这使得跟踪约束和视图变得容易得多)...因此,使用上述例外,我将在xcode(或其他编辑器)中以“源代码”的形式打开情节提要,并寻找可以找到的东西...<NSLayoutConstraint:0x72bf860 V:[UILabel:0x72bf7c0(17)]>&nbsp;..这看起来像UILabel上的垂直(V)约束,值为(17)。查看例外情况,我也发现<NSLayoutConstraint:0x72c22b0 V:[UILabel:0x72bf7c0]-(NSSpace(8))-[UIButton:0x886efe0]>看起来UILabel(0x72bf7c0)接近于UIButton(0x886efe0),并具有一定的垂直间距(8)。希望这足以让我在情节提要源代码中找到特定的视图(可能是通过最初在文本中搜索“ 17”)或至少一些可能的候选者。从那里,我应该能够真正找出这些故事在情节提要中的哪些视图,这将使查找问题变得容易得多(查找“重复的”固定或固定与大小限制冲突的位置)。

qq_遁去的一_1

请注意,不要在同一方向和类型上使用多个约束。例如: 尾随的垂直约束= 15,而另一个约束> = 10。有时,Xcode会创建一些您没有注意到的约束。您必须摆脱冗余约束,日志警告肯定会消失。另外,您可以直接从日志中读取和检测某些特定原因:NSLayoutConstraint:0xa338390 V:|-(15)-[UILabel:0xa331260](名称:'|':UILabel:0xa330270)>这可以理解为UILabel约束中的问题,它导致垂直约束长15pt。NSLayoutConstraint:0x859ab20 H :-( 13)-| [UIView:0x85a8fb0] ...这将是尾随水平约束等。
打开App,查看更多内容
随时随地看视频慕课网APP