UICollectionView:

来源:互联网 发布:mac硬盘格式化方案 编辑:程序博客网 时间:2024/05/16 00:34

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 allocinit];

    flowLayout.headerReferenceSize = CGSizeMake(300.0f, 50.0f);  //设置head大小

    return flowLayout;

}


0 0
原创粉丝点击