Skip to content

Instantly share code, notes, and snippets.

@yuxiangq
Created December 14, 2014 13:43
Show Gist options
  • Save yuxiangq/0c5aa8c4dd9ebc97047a to your computer and use it in GitHub Desktop.
Save yuxiangq/0c5aa8c4dd9ebc97047a to your computer and use it in GitHub Desktop.
UICollectionViewDataSource的回调方法
//返回有多少个Section,该方法和UITableView的一样
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
return 1;
}
//返回每个Section有多少rows
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return 1;
}
//返回cell
-(UICollectionViewCell*)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
UICollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:kCollectionCellIdentifier forIndexPath:indexPath];
cell.contentView.backgroundColor=[UIColor whiteColor];
return cell;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment