我正在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/