UICollectionView:
-(id)initWithCoder:(NSCoder *)aDecoder{
if(self =[super initWithCoder:aDecoder]){
return [self init];
}
return self;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return self.products.count;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
LJProductCollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
cell.productItem=self.products[indexPath.row];
return cell;
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
LJProductBaseViewController *productDetailVC=[[LJProductBaseViewController alloc]init];
[self.navigationController pushViewController:productDetailVC animated:YES];
}
- (UICollectionViewFlowLayout *) flowLayout{
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
flowLayout.headerReferenceSize = CGSizeMake(300.0f, 50.0f); //设置head大小
return flowLayout;
}