IOS UICollectionView使用

来源:互联网 发布:淘宝装修教程 编辑:程序博客网 时间:2024/06/06 00:34

@interface ProductShowViewController : BaseViewController<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,MJRefreshBaseViewDelegate>@property(nonatomic,retain) IBOutlet UICollectionView *CV_Prouct_list;//上拉加载@property(nonatomic, strong)MJRefreshFooterView *Footer;@end


#pragma mark -- UICollectionViewDataSource/** * 设置UICollectionViewCell显示的内容 */-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{            static NSString *CellIdentifier = @"ProductShowCollectionCell";            UINib *nib = [UINib nibWithNibName:@"ProductShowCollectionViewCell" bundle:[NSBundle mainBundle]];    [collectionView registerNib:nib forCellWithReuseIdentifier:CellIdentifier];        ProductShowCollectionViewCell *cell = (ProductShowCollectionViewCell*)[collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];        cell.IV_image.image = [UIImage imageNamed:@"guide-1.jpg"];    cell.LB_name.text = @"某某某有限公司";    cell.layer.borderWidth = 1;    cell.layer.borderColor = [[UIColor whiteColor] CGColor];    return cell;}/** * 设置UICollectionView项的个数 */-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{    return 24;}/** * 设置展现section的个数 **/-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{    return 1;}#pragma mark -- UICollectionViewDelegateFlowLayout/** * 设置UICollectionViewCell的大小 */-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{    double width = (self.view.bounds.size.width - 200) / 4;    return CGSizeMake(width, width);}/** * 设置UICollectionViewCell四边距 **/-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{    return UIEdgeInsetsMake(30, 40, 10, 40);}/** * UICollectionView两列之间最小的间距 */-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{    return 0.0f;}/** * UICollectionView两行之间最小的间距 */- (CGFloat) collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section{    return 30.0f;}//----------------------------------------------------------------------------------UICollectionViewDataSource end


0 0