// // ZBHotSaleViewController.m // ZBProject // // Created by 学丽 on 2019/4/19. // Copyright © 2019 ZB. All rights reserved. // #import "ZBHotSaleViewController.h" @interface ZBHotSaleViewController () @property(nonatomic,strong)UICollectionView *collectionV; @property(nonatomic,strong)NSMutableArray *dataArray; @property(nonatomic,assign)NSInteger Page; @end @implementation ZBHotSaleViewController - (void)viewDidLoad { [super viewDidLoad]; [self setNavs]; } #pragma mark----collectionView||delegate&Datasource -(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { ZBHotSaleListCell *shopC =[collectionView dequeueReusableCellWithReuseIdentifier:@"data" forIndexPath:indexPath]; // shopC.model=self.dataArray[indexPath.row]; return shopC; } -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { ZBGoodDetailVC *detailVC = [[ZBGoodDetailVC alloc] init]; detailVC.model = self.dataArray[indexPath.row]; [self.navigationController pushViewController:detailVC animated:YES]; } -(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { return CGSizeMake(SCREEN_WIDTH, 130); } -(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return 4; // return self.dataArray.count; } -(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { return 1; } -(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section { return UIEdgeInsetsMake(0, 0, 0, 0);//分别为上、左、下、右 } -(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section { return CGSizeMake(SCREEN_WIDTH, 0); } -(void)setNavs { self.Page = 1; [self.view addSubview:self.collectionV]; [self.collectionV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.right.mas_equalTo(0); make.top.mas_equalTo(NavBarHeight); make.height.mas_equalTo(SCREEN_HEIGHT); }]; self.view.backgroundColor=[UIColor lineColor]; self.navBar.backgroundColor=[UIColor whiteColor]; self.navBar.navTitleLabel.textColor=[UIColor blackColor]; self.navBar.navTitleLabel.text=@"热销榜"; self.navigationController.navigationBar.hidden=NO; UIButton *returnBtn =[[UIButton alloc]initWithFrame:CGRectMake(0, 0, 30, 20)]; [returnBtn addTarget:self action:@selector(returnClickBtn) forControlEvents:UIControlEventTouchUpInside]; [returnBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal]; returnBtn.adjustsImageWhenHighlighted = NO; [self.navBar setCustomLeftButtons:@[returnBtn]]; [self.navBar setShowNavigationBarBottomLine:YES]; } -(void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; self.navigationController.navigationBar.hidden=NO; } -(void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; self.navBar.hidden=NO; [UIApplication sharedApplication].statusBarStyle=UIStatusBarStyleDefault; } -(void)returnClickBtn { [self.navigationController popViewControllerAnimated:YES]; } -(UICollectionView *)collectionV { if (!_collectionV) { UICollectionViewFlowLayout *flowLayout =[[UICollectionViewFlowLayout alloc]init]; flowLayout.minimumLineSpacing = 1; flowLayout.minimumInteritemSpacing = 0; _collectionV =[[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) collectionViewLayout:flowLayout]; _collectionV.delegate=self; _collectionV.dataSource=self; _collectionV.showsVerticalScrollIndicator=NO; _collectionV.showsHorizontalScrollIndicator=NO; _collectionV.backgroundColor=[UIColor clearColor]; [_collectionV registerClass:[ZBHotSaleListCell class] forCellWithReuseIdentifier:@"data"]; self.collectionV.mj_header =[MJRefreshNormalHeader headerWithRefreshingBlock:^{ self.Page = 1; // [self getProductData]; }]; self.collectionV.mj_footer=[MJRefreshBackNormalFooter footerWithRefreshingBlock:^{ self.Page ++; // [self getProductData]; }]; } return _collectionV; } -(NSMutableArray *)dataArray { if (!_dataArray) { _dataArray =[NSMutableArray array]; } return _dataArray; } @end