// // TFBookStoreComicMiddleStyleCell.m // TFReader // // Created by 谢腾飞 on 2020/12/16. // Copyright © 2020 xtfei_2011@126.com. All rights reserved. // #import "TFBookStoreComicMiddleStyleCell.h" #import "TFBookStoreComicMiddleItemCell.h" @interface TFBookStoreComicMiddleStyleCell () @end @implementation TFBookStoreComicMiddleStyleCell static NSString *cellID = @"TFBookStoreComicMiddleItemCell"; - (void)createSubviews { [super createSubviews]; self.collectionView.delegate = self; self.collectionView.dataSource = self; [self.collectionView registerClass:[TFBookStoreComicMiddleItemCell class] forCellWithReuseIdentifier:cellID]; } - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return self.labelModel.list.count <= 4 ? self.labelModel.list.count : 4; } - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { TFBookStoreComicMiddleItemCell __weak *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath]; cell.productionModel = [self.labelModel.list objectOrNilAtIndex:indexPath.row]; return cell; } - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { return CGSizeMake(Comic_MiddleCell_Width, Comic_MiddleCell_Height); } - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { TFProductionModel *production = [self.labelModel.list objectOrNilAtIndex:indexPath.row]; if (self.cellDidSelectItemBlock) { self.cellDidSelectItemBlock(production.production_id); } } @end