//
|
// childTableViewCell.m
|
// XYRVideo
|
//
|
// Created by apple on 16/12/24.
|
// Copyright © 2016年 yeshi. All rights reserved.
|
//
|
|
#import "childTableViewCell.h"
|
#import "recommentCollectionViewCell.h"
|
|
@interface childTableViewCell() <UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout>
|
@property (weak, nonatomic) IBOutlet UICollectionView *cellColletionView;
|
|
@end
|
|
@implementation childTableViewCell
|
|
- (void)awakeFromNib {
|
[super awakeFromNib];
|
// Initialization code
|
_cellColletionView.delegate=self;
|
_cellColletionView.dataSource=self;
|
|
//注册瀑布流的cell
|
[_cellColletionView registerNib:[UINib nibWithNibName:@"recommentCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"recommentCollectionViewCell"];
|
|
//隐藏滚动条
|
_cellColletionView.showsVerticalScrollIndicator=NO;
|
_cellColletionView.showsHorizontalScrollIndicator=NO;
|
|
//设置背景色为透明
|
self.backgroundColor=[UIColor clearColor];
|
_cellColletionView.backgroundColor=[UIColor clearColor];
|
|
UICollectionViewFlowLayout *flow = [[UICollectionViewFlowLayout alloc] init];
|
//指定布局方式为垂直
|
flow.scrollDirection = UICollectionViewScrollDirectionVertical;
|
|
flow.minimumLineSpacing = 10;//最小行间距(当垂直布局时是行间距,当水平布局时可以理解为列间距)
|
flow.minimumInteritemSpacing = 5;//两个单元格之间的最小间距
|
|
[_cellColletionView setCollectionViewLayout:flow];
|
}
|
|
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
|
[super setSelected:selected animated:animated];
|
// Configure the view for the selected state
|
|
}
|
|
#pragma mark -UICollectionViewDataSource
|
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
|
return self.cellData.count;
|
}
|
|
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
|
NSDictionary *tempDic=[_cellData[indexPath.row] objectForKey:@"Video"];
|
recommentCollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:@"recommentCollectionViewCell" forIndexPath:indexPath];
|
[cell.recommentImageView setYthImageWithURL:[tempDic objectForKey:@"Picture"] placeholderImage:[UIImage imageNamed:@"默认加载图片"]];
|
cell.recommentTitleLabel.text=[NSString stringWithFormat:@"%@\n",[tempDic objectForKey:@"Name"]];
|
return cell;
|
}
|
|
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
|
return 1;
|
}
|
|
#pragma mark -UICollectionViewDelegate
|
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
|
NSIndexPath *index=[NSIndexPath indexPathForRow:indexPath.row inSection:_tableViewindex.section];
|
self.clickIndexpath(index);
|
}
|
|
#pragma mark -UICollectionViewDelegateFlowLayout
|
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
|
return CGSizeMake((KScreenW-40)/3, KGlobalCellH+35);
|
}
|
|
-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
|
return UIEdgeInsetsMake(0, 10, 0, 10);//分别为上、左、下、右
|
}
|
|
@end
|