I have two view controllers. First one is Custom view controller that loads the images from asset library. Second view controller shows the full size of selected image with cancel & Delete button
I have used the below code for delete the selected image from custom view controller. customviewcontroller.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];
}
This working fine for delete the selected image from custom view controller. but It works also cancel. Now, I want to control deletion on cancel. kindly help me to solve this.
I have already tried using button tag for identify which button was pressed. but can't control in custom vc secondview.m
- (IBAction)CancelPhoto:(id)sender{
[Cancel setTag:1]; //set tag value at cancel
}