// // BogoSearchVideoListCell.m // BuguLive // // Created by Mac on 2021/9/27. // Copyright © 2021 xfg. All rights reserved. // #import "BogoSearchVideoListCell.h" #import "SmallVideoCell.h" @interface BogoSearchVideoListCell () @property (weak, nonatomic) IBOutlet UICollectionView *collectionView; @end @implementation BogoSearchVideoListCell - (void)awakeFromNib { [super awakeFromNib]; // Initialization code self.collectionView.delegate = self; self.collectionView.dataSource = self; [self.collectionView registerNib:[UINib nibWithNibName:@"SmallVideoCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"SmallVideoCell"]; } - (void)setDataArray:(NSArray *)dataArray{ _dataArray = dataArray; [self.collectionView reloadData]; } #pragma mark - UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{ return 1; } - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ return self.dataArray.count; } - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ SmallVideoCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"SmallVideoCell" forIndexPath:indexPath]; if (indexPath.item < self.dataArray.count) { [cell creatCellWithModel:self.dataArray[indexPath.item] andRow:(int)indexPath.item]; } return cell; } - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{ CGFloat width = floor(( kScreenW - 25 ) / 2); return CGSizeMake(width, self.height - 25); } - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{ return UIEdgeInsetsMake(10, 10, 15, 10); } - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section{ return 0; } - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{ return 5; } - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ if (self.delegate && [self.delegate respondsToSelector:@selector(videoListCell:didClickVideo:)]) { [self.delegate videoListCell:self didClickVideo:self.dataArray[indexPath.item]]; } } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } @end