UICollectionView 单元格中的两个视图。UIImageView 和 UIView 。像这样:布局
但是当我做约束时,我得到一个错误:
无法同时满足约束
imgView.snp_makeConstraints { make in
make.top.equalTo(contentView)//.inset(K.Space.Small)
//make.bottom.equalTo(self.descView.snp_top)//.inset(K.Space.Small.negative())
make.left.right.equalTo(contentView)
}
descView.snp_makeConstraints { make in
make.bottom.equalTo(contentView)
make.left.right.bottom.equalTo(contentView)
make.height.equalTo(44)
make.top.equalTo(imgView.snp_bottom)
}
错误: 错误
为什么?
编辑:在 vc viewDidLoad 方法中初始化集合视图。【layout.itemSize】在ViewController中第一次出现错误。但向下滚动没有错误。
let collectionContentInset = UIEdgeInsets(top: 0, left: 12, bottom: 0, right: 12)
var collectionItemSize = DXLayoutSize(aspectRatio: 1.35)
collectionItemSize.containerInset = collectionContentInset
let layout = UICollectionViewFlowLayout()
layout.itemSize = collectionItemSize.itemSize()
layout.minimumInteritemSpacing = 6;
layout.minimumLineSpacing = 0;
collectionView = UICollectionView(frame: CGRectZero, collectionViewLayout: layout)
collectionView!.backgroundColor = DXUIColor.Background.color()
collectionView!.showsHorizontalScrollIndicator = false
collectionView!.contentInset = collectionContentInset