Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specify row and column number for UICollectionView

Tags:

I want to show a UICollectionView which contains exactly 2 rows and 100 cells in each row.

// 1 - (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSInteger)section {      return 100; } // 2 - (NSInteger)numberOfSectionsInCollectionView: (UICollectionView *)collectionView {     return 2; } // 3 - (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath {     MyCell *cell = [cv dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];          cell.lbl.text = @"Data";      return cell; } 

I am getting this:

enter image description here

How can I specify a row number for UICollectionView? I want to create a 2x100 table.

like image 353
onivi Avatar asked Sep 25 '13 16:09

onivi


1 Answers

Try this:

// 1 - (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSInteger)section {      return 2; } // 2 - (NSInteger)numberOfSectionsInCollectionView: (UICollectionView *)collectionView {     return 100; } // 3 - (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath {     MyCell *cell = [cv dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];          cell.lbl.text = @"Data";      return cell; } 
like image 64
amone Avatar answered Sep 21 '22 13:09

amone