UICollectionView Cell中的两个视图。 UIImageView和UIView。像这样:layout
但是当我制定约束时,我收到一个错误:
无法同时满足约束
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)
}
错误: error
编辑:vc viewDidLoad方法中的init集合视图。 【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
答案 0 :(得分:1)
查看错误消息。它表示您有NSAutoResizingMaskLayoutConstraint
将contentView
的高度和宽度设置为0.只需禁用通过自动调整蒙版创建约束:
contentView.translatesAutoresizingMaskIntoConstraints = false