我很欣赏 XCode 会捕捉到无法满足的情况NSLayoutConstraints
并为您提供一些有关它的信息,但是我不知道如何获取控件/约束的内存地址并将其映射到有问题的实际控件。
我的应用程序相当大(大约 20 个屏幕),其中一些是大型 UIViewControllers,其中包含多个子视图控制器。有些是带有自定义单元格的 UITableViews 和带有自定义单元格的 UICollectionViews。我花了很多时间来解决这个错误的原因(发生在横向旋转时)
这是来自我的控制台的信息:
2013-05-02 11:18:53.225 Smile[7519:c07] 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:0x16083b60 h=-&- v=-&- UIView:0xa5a1d00.width == UIWindow:0xa09eee0.width>",
"<NSLayoutConstraint:0xa5a2180 V:[UIView:0xa59f160]-(954)-| (Names: '|':UIView:0xa5a1d00 )>",
"<NSLayoutConstraint:0xa5a2140 V:|-(0)-[UIView:0xa59f160] (Names: '|':UIView:0xa5a1d00 )>",
"<NSAutoresizingMaskLayoutConstraint:0xa593340 h=--- v=--- H:[UIWindow:0xa09eee0(768)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0xa5a2180 V:[UIView:0xa59f160]-(954)-| (Names: '|':UIView:0xa5a1d00 )>
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.
如您所见,列出了内存地址。将这些粘贴到监视窗口的搜索栏中并没有透露太多信息。同样筛选线程和队列调用堆栈,我只在这个断点(异常断点)上得到反汇编代码。