<分区>
我有两个 View Controller 。 第一个是自定义 View Controller ,它从 Assets 库加载图像。 第二个 View Controller 显示带有取消和删除按钮的所选图像的完整尺寸
我使用下面的代码从自定义 View Controller 中删除选定的图像。 自定义 View Controller .m
-(void)deleteItemsFromDataSourceAtIndexPaths:(NSArray *)itemPaths
{
//here i want to control the delete option when cancel pressed
NSMutableIndexSet *indexSet = [NSMutableIndexSet indexSet];
for (NSIndexPath *itemPath in itemPaths) {
[indexSet addIndex:itemPath.row];
}
[self.selectedAssets removeObjectsAtIndexes:indexSet];
}
/* call the delete function*/
- (void) collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
NSArray *selectedItemsIndexPaths = [self.collectionview1 indexPathsForSelectedItems];
[self deleteItemsFromDataSourceAtIndexPaths:selectedItemsIndexPaths];
[self.collectionview1 deleteItemsAtIndexPaths:selectedItemsIndexPaths];
}
这适用于从自定义 View Controller 中删除所选图像。 但它也可以取消。现在,我想在取消时控制删除。 请帮我解决这个问题。
我已经尝试使用按钮标签来识别按下了哪个按钮。但无法在自定义 vc 中控制 secondview.m
- (IBAction)CancelPhoto:(id)sender{
[Cancel setTag:1]; //set tag value at cancel
}