我的CollectionView是在自定义的TableViewCell里面编写的。如何让CollectionView滚动时的高度,与TableView单元格的高度相同,并让CollectionView和TableView联动。
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
_detailCollectionview = [[UICollectionView alloc]initWithFrame:CGRectMake(0,0, MainScreenWidth, MainScreenHeight) collectionViewLayout:self.layout];
_detailCollectionview.backgroundColor = [UIColor whiteColor];
[self.contentView addSubview:_detailCollectionview];
_detailCollectionview.delegate = self;
_detailCollectionview.dataSource = self;
[_detailCollectionview registerNib:[UINib nibWithNibName:@"WaterFallCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"detailcell"];
[self.contentView addSubview:_detailCollectionview];
}
return self;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
WaterFallCollectionViewCell * cell = (WaterFallCollectionViewCell*)[collectionView dequeueReusableCellWithReuseIdentifier:@"detailcell" forIndexPath:indexPath];
HEPShopModel *model = self.modelArray[indexPath.row];
[cell updateCellWithWaterFallModel:model];
return cell;
}