为什么当我创建一个CollectionView并使用不同的标识符对两个单元格转换时,后者是彼此相连的? 具有相同标识符的小区具有相同的距离,而不同标识符的小区粘在一起。 这里我的代码:单元格在UICollectionView中相互连接
- (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;
}
请帮帮我!
目前尚不清楚你的意思。 PictureCells是相互粘在一起的,还是粘在AddCell上的? – rdelmar
当标识符更改时,CollectionViewCell将自身附加到具有不同标识符的另一个单元格。也就是说,我有3个带有AddCell标识符的单元格,以及6个带有PictureCell标识符的单元格。当标识符发生变化并因此从AddCell更改为PictureCell时,最后一个AddCell单元格将其自身附加到第一个PictureCell单元 – Joker
这两种单元格的大小是否不同? – rdelmar