gpt4 book ai didi

ios - SnapKit 自动布局损坏 : "Unable to simultaneously satisfy constraints"

转载 作者:行者123 更新时间:2023-11-29 01:05:09 28 4
gpt4 key购买 nike

UICollectionView Cell 中的两个 View 。 UIImageView 和 UIView 。像这样:layout

但是当我进行约束时,出现错误:

Unable to simultaneously satisfy constraints

    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方法中初始化 Collection View 。 【布局.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

最佳答案

查看错误消息。它表示您有一个 NSAutoResizingMaskLayoutConstraint ,它将 contentView 的高度和宽度设置为 0。只需禁用从自动调整大小蒙版创建约束即可:

contentView.translatesAutoresizingMaskIntoConstraints = false

关于ios - SnapKit 自动布局损坏 : "Unable to simultaneously satisfy constraints",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36493540/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com