Ios UICollectionview节/行/阵列
我想用UICollectionView做点什么。我希望它们以中间为中心,但为此我需要创建这样的东西:Ios UICollectionview节/行/阵列,ios,objective-c,uicollectionview,Ios,Objective C,Uicollectionview,我想用UICollectionView做点什么。我希望它们以中间为中心,但为此我需要创建这样的东西: (Array consists of 5 items) X X <- 2 items in section 1 X X <- 2 items in section 2 X <- 1 item in section 3 谁能帮我在正确的单元格中显示正确的文本 亲切问候在cellForItemAtIndexPath: - (UICollectionViewCell *)col
(Array consists of 5 items)
X X <- 2 items in section 1
X X <- 2 items in section 2
X <- 1 item in section 3
谁能帮我在正确的单元格中显示正确的文本
亲切问候在
cellForItemAtIndexPath:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
....
//since there is 2 items in each section
int index = 2*indexPath.section + indexPath.row;
[[cell detaildiceLabel] setText: [NSString stringWithFormat:@"%@", [[arrayDobbel objectAtIndex:index] returnRandomOptie]]];
return cell;
}
您可以使用
部分
和行
,并且部分
未在您的集合视图中使用:cellForItemAtIndexPath:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
....
//since there is 2 items in each section
int index = 2*indexPath.section + indexPath.row;
[[cell detaildiceLabel] setText: [NSString stringWithFormat:@"%@", [[arrayDobbel objectAtIndex:index] returnRandomOptie]]];
return cell;
}