UICollectionView细胞+的UILabel与自动版式 [英] UICollectionView Cell + UiLabel with AutoLayout
问题描述
我想它的父细胞的脚的UILabel。我添加了四个约束(顶部,前置,底部)的正常工作在iOS 8.0而不是在iOS 7.X 。请参见下图:
我是什么做错了吗?请指教!
编辑#1
看来它,因为X code 6通用汽车的唯一打破。我的做法是工作的罚款在X code 6测试版7。
此外,如果我减少内部视图的宽度,它抛出以下警告:
2014年9月10日19:58:28.109测试[57827:60B]无法同时满足约束条件。
大概在以下列表中的约束条件中的至少一个是一个你不想要的。试试这个:(1)看一下每个约束和揣摩,你不要指望; (2)找到code,它增加了不必要的约束或限制并修复它。 (注:如果你看到你不明白NSAutoresizingMaskLayoutConstraints,请参阅文档UIView的财产translatesAutoresizingMaskIntoConstraints)
(
< NSLayoutConstraint:0x799573a0 H:| - (8) - [UIView的:0x798a86e0](名称:'|':的UIView:0x798ae5d0)>中,
< NSLayoutConstraint:0x799573d0 H:[UIView的:0x798a86e0] - (43) - |(名称:'|':的UIView:0x798ae5d0)>中,
&所述; NSAutoresizingMaskLayoutConstraint:0x798a8b00 H = - &放大器; V = - &放大器; H:[UIView的:0x798ae5d0(50)] gt;中
)将试图打破约束恢复
&所述; NSLayoutConstraint:0x799573d0 H:[UIView的:0x798a86e0] - (43) - | (名称:'|':的UIView:0x798ae5d0)>打破objc_exception_throw赶上这在调试器。
在UIView的的UIConstraintBasedLayoutDebugging类别中列出的方法<的UIKit / UIView.h>也可能是有帮助的。
重写自定义单元格的 layoutSubviews
是一个可能的解决方法:
覆盖FUNC layoutSubviews(){
contentView.frame =界限
super.layoutSubviews()
}
I'm trying to pin an UILabel to it's parent cell. I added four constraints (top, leading, trailing, bottom) which works fine on iOS 8.0 but not on iOS 7.X. Please see image below:
What am I doing wrong? Please advise!
EDIT #1
It seems it's only broken since Xcode 6 GM. My approach was working fine in Xcode 6 beta 7.
Moreover, if I decrease the inner view's width, it throws the following warning:
2014-09-10 19:58:28.109 Test[57827:60b] 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:0x799573a0 H:|-(8)-[UIView:0x798a86e0] (Names: '|':UIView:0x798ae5d0 )>",
"<NSLayoutConstraint:0x799573d0 H:[UIView:0x798a86e0]-(43)-| (Names: '|':UIView:0x798ae5d0 )>",
"<NSAutoresizingMaskLayoutConstraint:0x798a8b00 h=--& v=--& H:[UIView:0x798ae5d0(50)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x799573d0 H:[UIView:0x798a86e0]-(43)-| (Names: '|':UIView:0x798ae5d0 )>
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.
Overriding the custom cell's layoutSubviews
is a possible workaround:
override func layoutSubviews() {
contentView.frame = bounds
super.layoutSubviews()
}
这篇关于UICollectionView细胞+的UILabel与自动版式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!