iphone - 如何从UICollectionView删除项目?

标签 iphone ios uicollectionview uicollectionviewcell

我正在collection view上显示图像。我想删除button click上的每个项目。现在,我可以删除didSelect method上的项目。

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    [array removeObjectAtIndex:indexPath.row];
    [self.colleVIew deleteItemsAtIndexPaths:[NSArray arrayWithObject:indexPath]];
}

我在CollectionCell上放置了按钮,可以找到indexpath.row on click。但是如何删除
-(void)chat:(int)i 
{
    NSLog(@"index path%d",i);
    [array removeObjectAtIndex:i]; // array object is getting removed,how to delete the CollectionviewCell
}

最佳答案

如果您也确实了解本节:

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:i inSection:0];
[self.colleVIew deleteItemsAtIndexPaths:[NSArray arrayWithObject:[indexPath]]];

关于iphone - 如何从UICollectionView删除项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16199275/

相关文章:

ios - Swift 中的 UICollectionView 部分边框

ios - 如何从代表的 Collection View 单元格中获取 indexPath 项?

ios - AnimateWithDuration 运行异常

iphone - 是否从 init 方法开始?

iphone - 核心数据关系的自定义 setter 强制反向、互惠关系

iphone - "autoreleased with no pool in place - just leaking"仅适用于 iOS 4.3

ios - 我们如何知道写入文件已完成

ios - 快速饼图切片

ios - UICollectionView performBatchUpdates 导致 collectionview 在旋转设备时错位

iphone - 将皮肤/主题添加到 iPhone 应用程序