我正在生成一个座位图,它的级别表示部分和座位,表示其中的单元数,但在此之前,有行数表示其中的座位数。但UICollectionView
其中只有部分和单元格。如何管理行。每个部分都有单元格,但如何在行下显示它们意味着每个部分都有行数。我设法显示部分和单元格,但不显示行。请指导以上。
提前致谢。
这是json
{
Level1:
{
row1:
{
1: "on",
2: "on",
3: "on",
4: "on",
5: "on",
6: "on",
7: "on",
8: "on",
9: "on",
10: "on",
attr: {
total: "10",
type: "gold"
}
},
row2: {
1: "on",
2: "on",
3: "on",
4: "on",
5: "on",
6: "on",
7: "on",
8: "on",
9: "on",
10: "on",
attr: {
total: "10",
type: "gold"
}
}
},
Level3: {
row1: {
1: "on",
2: "on",
3: "on",
4: "on",
5: "on",
6: "on",
7: "on",
8: "on",
9: "on",
10: "on",
attr: {
total: "10",
type: "silver"
}
}
}
}
上面的 json 将级别显示为节数,我的问题是如何按行显示单元格。
我正在做的方法是:
- (NSInteger)numberOfSectionsInCollectionView: (UICollectionView *)collectionView
{
NSLog(@"levels count:%d", [arrLevels count]);
return [arrLevels count];
}
- (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:@"%@",[arrSeats objectAtIndex:i]];
c = [cnt intValue];
return c;
}
}
return 1;
}