[英]Custom UICollectionViewCell Auto Layout NSInternalInconsistencyException error
[英]Auto Layout Error in a UICollectionViewCell
我正在嘗試在UI中調試自動布局沖突。
我已經使用IB設置了整個UI。
我遇到的問題與UICollectionView
子類(稱為FrameCell
對象FrameCell
。
FrameCell
具有一個UIImageView
和一個UILabel
,它們都在單元格中水平居中。
垂直約束是這樣的...
V:|-20-[UIImageView]-50-[UILabel(==26)]-25-|
也就是說, UIImageView
的高度根據單元格的大小是可變的。
但是我遇到了錯誤...
(
"<NSAutoresizingMaskLayoutConstraint:0x20087d00 h=--& v=--& V:[FrameCell:0x1edaf4a0(0)]>",
"<NSLayoutConstraint:0x1edafc10 UIImageView:0x1edaf960.top == FrameCell:0x1edaf4a0.top + 20>",
"<NSLayoutConstraint:0x1edafb50 FrameCell:0x1edaf4a0.bottom == UILabel:0x1edaf5c0.bottom + 25>",
"<NSLayoutConstraint:0x1edafb10 V:[UIImageView:0x1edaf960]-(50)-[UILabel:0x1edaf5c0]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x1edafb10 V:[UIImageView:0x1edaf960]-(50)-[UILabel:0x1edaf5c0]>
該錯誤幾乎可以肯定是由NSAutoresizingMaskLayoutConstraint引起的,但是我不確定如何消除此錯誤? 為什么將FrameCell的高度設置為0?
如果我嘗試關閉單元格中的translatesAutoresizingMaskIntoConstraints
,則會收到內部一致性錯誤。 我正在使用IB進行所有設置,因此不確定此AutoResizingMask來自何處?
我想知道在處理UICollectionViewCells中的約束時,IB是否有與UITableViewCells相同的問題?
請參閱@Adrians對這個問題的回答: iOS 6 UITableViewCell原型單元中的contentView不縮進
如果您想修正標簽尺寸而不是使用==,請嘗試一下,這可能對您有幫助
V:|-20-[UIImageView]-50-[UILabel(==26)]-25-|
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.