ios – 具有AutoLayout的UICollectionView单元格UiLabel

我试图将UILabel固定在它的父母单元上.我添加了四个约束(顶部,前导,尾随,底部),在iOS 8.0上可以正常工作,但不在iOS 7.X上.请看下图:

[Click here for full size]

我究竟做错了什么?请指教!

编辑#1

似乎它只是因为Xcode 6通用汽车破碎了.我的方法在Xcode 6 beta 7中正常工作.

此外,如果我减小内部视图的宽度,它会引发以下警告:

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.

解决方法

覆盖自定义单元格的layoutSubviews是一种可能的解决方法
override func layoutSubviews() {
    contentView.frame = bounds
    super.layoutSubviews()
}

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...