【发布时间】:2016-04-08 07:05:36
【问题描述】:
UICollectionView 单元格中的两个视图。 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 方法中初始化集合视图。 【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
【问题讨论】:
-
我相信这是因为您将 descView 的顶部设置为 imgView 的底部,但仍要求 descView 的高度为 44 并保持固定在 contentView 的底部。这限制太多了。
标签: ios swift autolayout uicollectionviewcell snapkit