我希望在单击按钮时删除 UICollectionView 中的所有项目。单击该按钮时,会弹出一条警告消息。点击“确定”后,应删除集合视图中的项目。到目前为止,我已经使用了以下代码:
NSArray *selectedItemsIndexPaths = [self.collectionView indexPathsForSelectedItems];
[self deleteItemsFromDataSourceAtIndexPaths:selectedItemsIndexPaths];
[self.collectionView deleteItemsAtIndexPaths:selectedItemsIndexPaths];
-(void)deleteItemsFromDataSourceAtIndexPaths:(NSArray *)itemPaths
{
NSMutableIndexSet *indexSet = [NSMutableIndexSet indexSet];
for (NSIndexPath *itemPath in itemPaths) {
[indexSet addIndex:itemPath.row];
}
[self.collectionViewData removeObjectsAtIndexes:indexSet];
}
前三行代码在警报视图的“clickedButtonAtIndex”内。我哪里错了?