设置make.height.mas_equalTo(500);后报错
[self.view addSubview:self.categoryDetailView];
[self.categoryDetailView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(64);
make.right.mas_equalTo(0);
make.width.mas_equalTo([UIScreen mainScreen].bounds.size.width-100);
make.height.mas_equalTo(500);
}];
下面是流水布局
- (UICollectionViewFlowLayout *)flowlayout{
if (!_flowlayout) {
_flowlayout = [[UICollectionViewFlowLayout alloc]init];
_flowlayout.sectionInset = UIEdgeInsetsMake(5, 5, 5, 5);
_flowlayout.itemSize = CGSizeMake(100, 100);
//横向间距
_flowlayout.minimumInteritemSpacing = 5;
//纵向间距
_flowlayout.minimumLineSpacing = 10;
}
return _flowlayout;
}
下面是UICollectionView的初始化
- (UICollectionView *)categoryDetailView{
if (!_categoryDetailView) {
_categoryDetailView = [[UICollectionView alloc]initWithFrame:CGRectZero collectionViewLayout:self.flowlayout];
_categoryDetailView.delegate = self;
_categoryDetailView.dataSource = self;
_categoryDetailView.backgroundColor = [UIColor greenColor];
[_categoryDetailView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"item"];
}
return _categoryDetailView;
}
错误描述* Assertion failure in -[MASViewConstraint setSecondViewAttribute:], /Users/a1/tuyy/ChinaUnion/ChinaUnion/Lib/Masonry/MASViewConstraint.m:130
真的纠结了,请大神帮我看看
你好,解决了吗,我也遇到这样的问题了
应该是还少个bottom约束 contentview无法推算出高度
可以打断点分段测试一下、、我之前遇到过、问题是控件没有被初始化出来就使用它的位置了
总于解决了, 还是自己代码的问题
我的是两个collectionView之间布局有点冲突