在控制台上获取奇怪的日志消息(AutoLayout)

时间:2015-07-13 07:59:55

标签: ios autolayout uicollectionview size-classes

Hiii Guys,

我有600 * 450大小的视图,现在我将视图放在600 * 430大小的视图中。当我正在运行应用程序时,我在控制台上收到这个奇怪的消息

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:0x600000285960 V:|-(0)-[UICollectionView:0x7fb133860800]   (Names: '|':UIView:0x60000019df60 )>",
"<NSLayoutConstraint:0x600000285a50 V:[UICollectionView:0x7fb133860800]-(20)-|   (Names: '|':UIView:0x60000019df60 )>",
"<NSLayoutConstraint:0x600000285dc0 V:[_UILayoutGuide:0x6000001b5b60]-(0)-[UIView:0x60000019dc20]>",
"<NSLayoutConstraint:0x600000285e10 UIView:0x60000019dc20.height == 0.25*UIView:0x60000019db50.height>",
"<NSLayoutConstraint:0x6000002860e0 V:[_UILayoutGuide:0x6000001b5b60]-(0)-[UIView:0x60800019d5a0]>",
"<NSLayoutConstraint:0x600000286180 UIView:0x60000019df60.bottom == UIView:0x60000019ddc0.bottom>",
"<NSLayoutConstraint:0x600000286220 UIView:0x60000019df60.top == UIView:0x60800019d5a0.top>",
"<NSLayoutConstraint:0x600000286540 UIView:0x60000019dcf0.height == 0.25*UIView:0x60000019db50.height>",
"<NSLayoutConstraint:0x600000286590 V:[UIView:0x60000019dc20]-(0)-[UIView:0x60000019dcf0]>",
"<NSLayoutConstraint:0x6000002867c0 UIView:0x60000019ddc0.height == 0.25*UIView:0x60000019db50.height>",
"<NSLayoutConstraint:0x6000002868b0 V:[UIView:0x60000019dcf0]-(0)-[UIView:0x60000019ddc0]>",
"<NSLayoutConstraint:0x600000288d40 'UIView-Encapsulated-Layout-Height' V:[UIView:0x60000019db50(0)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x600000285a50 V:[UICollectionView:0x7fb133860800]-(20)-|   (Names: '|':UIView:0x60000019df60 )>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful. 

我不知道该怎么做。

enter image description here

我已将这4个约束应用于UICollectionView。

1 个答案:

答案 0 :(得分:0)

这是因为您添加的约束很少,因此最好选择视图,然后选择重置为建议约束。

enter image description here

如果此后如果约束不符合标记则更好地查找每个控制​​约束并检查哪个约束显示标记(黄色)并尝试手动删除然后添加。

希望它有所帮助。