为什么,当我创建一个 CollectionView 并将两个具有不同标识符的单元格出列时,后者相互附加?具有相同标识符的单元格之间的距离相等,而具有不同标识符的单元格则粘在一起。这是我的代码:
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
return 2;
}
- (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSInteger)section;
{
if (section == 0) {
return 1;
}
if (section == 1) {
return 10;
}
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath;
{
UICollectionViewCell *cell;
if (indexPath.section == 0) {
cell = [cv dequeueReusableCellWithReuseIdentifier:@"AddCell" forIndexPath:indexPath];
UIImageView *cellImage = (UIImageView *)[cell viewWithTag:1];
[cellImage setImage:[UIImage imageNamed:@"pulsante_trasparente.png"]];
}
else if (indexPath.section == 1){
cell = [cv dequeueReusableCellWithReuseIdentifier:@"PictureCell" forIndexPath:indexPath];
UIImageView *cellImage = (UIImageView*)[cell viewWithTag:1];
[cellImage setImage:[UIImage imageNamed:@"mi.png"]];
}
return cell;
}
请帮我!