以下是我在调试区收到的错误消息。它运行良好,除了我收到此错误之外没有任何问题。这会阻止苹果接受该应用程序吗?我该如何解决?
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.
最佳答案
我建议调试并找出哪个约束是“你不想要的”。假设您有以下问题:
问题始终是如何找到以下约束和 View 。
有两种解决方法:
由于您知道在哪里可以找到意外约束 (PBOUserWorkDayHeaderView),因此有一种方法可以很好地做到这一点。让我们在红色矩形中找到 UIView
和 NSLayoutConstraint
。因为我们知道他们的内存中的id,所以这很容易。
如您所见,内存指针是相同的。所以我们知道现在发生了什么。此外,您可以在 View 层次结构中找到 NSLayoutConstraint
。既然是在 View 中被选中的,那么在 Navigator 中也被选中了。
如果您需要,您也可以使用地址指针在控制台上打印:
(lldb) po 0x17dce920
<UIView: 0x17dce920; frame = (10 30; 300 24.5); autoresize = RM+BM; layer = <CALayer: 0x17dce9b0>>
您可以对调试器指向您的每个约束执行相同的操作:-) 现在您决定如何处理它。
更好地打印它 (我真的推荐这种方式,这是 Xcode 7 的)
NSLayoutConstraint
创建简单的扩展:SWIFT:
extension NSLayoutConstraint {
override public var description: String {
let id = identifier ?? ""
return "id: \(id), constant: \(constant)" //you may print whatever you want here
}
}
objective-C
@interface NSLayoutConstraint (Description)
@end
@implementation NSLayoutConstraint (Description)
-(NSString *)description {
return [NSString stringWithFormat:@"id: %@, constant: %f", self.identifier, self.constant];
}
@end
id
后,您可以在Find Navigator中轻按它:
如何简单地解决这种情况?
999
以防止约束失效。https://stackoverflow.com/questions/11664115/