#import “tiaoViewController.h”
@interface tiaoViewController ()<UICollectionViewDelegate,UICollectionViewDataSource>{
UICollectionView *clv;
}
@end
@implementation tiaoViewController
-
(void)viewDidLoad {
[super viewDidLoad];
UICollectionViewFlowLayout *lay=[UICollectionViewFlowLayout new];
lay.itemSize=CGSizeMake((self.view.frame.size.width-3)/4, (self.view.frame.size.width-3)/4);
lay.minimumLineSpacing=2;
lay.minimumInteritemSpacing=0;clv=[[UICollectionView alloc]initWithFrame:self.view.frame collectionViewLayout:lay];
clv.delegate=self;
clv.dataSource=self;
[self.view addSubview:clv];[clv registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@“cel”];
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return 12;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
UICollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:@“cel” forIndexPath:indexPath];
UIImageView *img=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, (self.view.frame.size.width-3)/4, (self.view.frame.size.width-3)/4)];
img.image=[UIImage imageNamed:@"02"];
[cell addSubview:img];
return cell;
}
@end