我有一个水平滚动的UICollectionView,我正在使用UICollectionViewFlowLayout设置水平方向。
当我删除其中一个单元格时-
[self.collectionView deleteItemsAtIndexPaths:selectedItemsIndexPaths];
我注意到,回滚到第一个UICollectionViewCell (当上面的单元格被删除时不可见)与第二个UICollectionViewCell重叠,如下所示
有时不是重叠,而是像这样-
我的cellForItemAtIndexPath看起来像-
ABCollectionViewCell *cell = (ABCollectionViewCell *)[cv dequeueReusableCellWithReuseIdentifier:@"abCell" forIndexPath:indexPath];
cell.name.text = [self.categoryArray objectAtIndex:indexPath.row];
cell.contactButton.tag = indexPath.row;
cell.layer.cornerRadius = 5.0;
cell.layer.borderColor = [UIColor lightGrayColor].CGColor;
cell.layer.borderWidth = 1.0;
cell.clipsToBounds = YES;
return cell;
我在网上尝试了所有类似的问题解决方案,但似乎没有一个有效。任何帮助都将不胜感激。
UICollectionViewFlowLayout -
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
[flowLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal];
flowLayout.estimatedItemSize = CGSizeMake(102.0, 102.0);
flowLayout.minimumLineSpacing = 6.0f;
flowLayout.minimumInteritemSpacing = 2.0f;
[self.collectionView setCollectionViewLayout:flowLayout];
发布于 2016-05-11 03:02:31
使用此函数
func collectionView(_ collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
insetForSectionAtIndex section: Int) -> UIEdgeInsets {
return UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 10)
}
发布于 2016-05-11 04:02:04
像这样执行delete
[self.collectionView performBatchUpdates:^{
[self.collectionView deleteItemsAtIndexPaths:selectedItemsIndexPaths];
} completion:^{
[self.collectionView layoutIfNeeded];
}];
https://stackoverflow.com/questions/37146099
复制相似问题