问题描述
- iOS开发 用masonry设置collection的高度时报错
- 设置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
真的纠结了,请大神帮我看看
时间: 2024-10-22 18:07:05