#pragma mark - 专项练习部分CollectionView
//懒加载
-(UICollectionView *)collection
{
if (!_collection) {
CGFloatitemHeight=banner_midheight;
CGFloatitemWidth =banner_midwidth;
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
//滚动方向->水平
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
//间距
layout.minimumLineSpacing=0;
layout.minimumInteritemSpacing = 0;
//每个item的size
layout.itemSize=CGSizeMake(itemWidth, itemHeight);
_collection = [[UICollectionView alloc]initWithFrame:CGRectMake(12, 0, SCREEN_WIDTH-24, banner_midheight+15) collectionViewLayout:layout];
_collection.hidden=NO;
_collection.backgroundColor=RGB(255,255,255);
_collection.delegate=self;
_collection.dataSource=self;
_collection.scrollsToTop=NO;//滚动到顶部->NO
_collection.showsHorizontalScrollIndicator = NO;//显示水平滚动条->NO
// _collection.backgroundColor = [UIColor redColor];
//滚动的时候快速衰弱
_collection.decelerationRate = UIScrollViewDecelerationRateFast;
// _collection.pagingEnabled = YES;//若是整页滚动,则使用
[_collection registerNib:[UINib nibWithNibName:@"MoKaoBannerCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"MoKaoBannerCollectionViewCell"];
[_collection registerNib:[UINib nibWithNibName:@"ExamBlackSpaceCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"ExamBlackSpaceCollectionViewCell"];
[_collection registerNib:[UINib nibWithNibName:@"GongjiAdBannerCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"GongjiAdBannerCollectionViewCell"];
}
return _collection;
}
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
return1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
if(self.exercisedata.count>0) {
returnself.exercisedata.count;
}
return0;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
Slide*object =self.exercisedata[indexPath.row];
GongjiAdBannerCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"GongjiAdBannerCollectionViewCell" forIndexPath:indexPath];
[cellsetContent:object];
returncell;
}
- (void)collectionView:(UICollectionView*)collectionViewdidSelectItemAtIndexPath:(NSIndexPath*)indexPath{
Slide*object =self.exercisedata[indexPath.row];
[Utils slideClick:self slide:object];
}
- (void)startMoKaoExercises:(SwitchExercisesModel*)exercisesModelwithIndex:(NSInteger)index{
MoKaoExercisesViewController *vc = [[MoKaoExercisesViewController alloc]init];
vc.scid= [NSStringstringWithFormat:@"%@",exercisesModel.id];
[self.navigationController pushViewController:vc animated:YES];
}
- (CGSize)collectionView:(UICollectionView*)collectionViewlayout:(UICollectionViewLayout*)collectionViewLayoutsizeForItemAtIndexPath:(NSIndexPath*)indexPath
{
return CGSizeMake(banner_midwidth, banner_midheight);
}