【发布时间】:2014-01-22 07:52:43
【问题描述】:
我目前正在使用带有自动布局的 xib 在集合视图中创建自定义单元格。我有两个方向的不同单元格大小。因此,我根据方向更改单元格的宽度和高度。
问题是,当我更改设备方向时,我会在 iOS6 中收到大量警告/异常。
但是,当我在 iOS7 中执行相同操作时,没有警告。
虽然它不会影响我的功能,但我想删除所有这些警告。
这是我的XIB file
以下是我得到的错误/警告/异常。
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:0x164371f0 V:[UILabel:0x16437240(21)]>",
"<NSLayoutConstraint:0x16438050 V:[UILabel:0x16437240]-(1)-[UILabel:0x16437670]>",
"<NSLayoutConstraint:0x16437fd0 V:[UILabel:0x16437670]-(5)-| (Names: '|':LibraryCollectionViewCell:0x16436ae0 )>",
"<NSLayoutConstraint:0x16437f50 V:[UILabel:0x16436e10]-(0)-[UILabel:0x16437240]>",
"<NSLayoutConstraint:0x16437e90 V:|-(7)-[UILabel:0x16436e10] (Names: '|':LibraryCollectionViewCell:0x16436ae0 )>",
"<NSAutoresizingMaskLayoutConstraint:0x16354d00 h=--& v=--& V:[UICollectionView:0xb24f200(264)]>",
"<NSAutoresizingMaskLayoutConstraint:0x163513b0 h=-&- v=-&- LibraryCollectionViewCell:0x16436ae0.height == UICollectionView:0xb24f200.height - 264>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x164371f0 V:[UILabel:0x16437240(21)]>
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.
我尝试过[cell setTranslatesAutoresizingMaskIntoConstraints:NO],但它反而使应用程序崩溃。
谁能提供一些解决方案?
【问题讨论】:
标签: ios objective-c ipad autolayout