1

如何在 UICollectionView 的不同部分显示不同数量的单元格。请为此提供任何示例。

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
for(int i=0; i<[arrSeatSel count]; i++)
{
    int c;
    NSString *cnt = [NSString stringWithFormat:@"%@",[arrSeatSel objectAtIndex:i]];
    c = [cnt intValue];
    return c;
}
return 1;
}

提前致谢。

4

2 回答 2

0

use this UICollectionView Datasource and Delegate method

   - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {

       if (section==1) {

            return [arrSearchCelebs count]; // your array count.

       }
       else if (section==2){
           return 2;
       }
       else {
           return 5;
       }
    }

it is same as UITableView's delegate and datasource method..

于 2013-05-16T12:27:45.203 回答
0

这样做

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
NSLog(@"vals count:%d", [arrSeats count]);
for(int i=0; i<[arrLevels count]; i++)
{
    if(section == i)
    {
        int c;
        NSString *cnt = [NSString stringWithFormat:@"%@",[arrTot objectAtIndex:i]];
        c = [cnt intValue];
        return c;
    }
}
return 1;
}
于 2013-05-22T06:25:39.817 回答