gpt4 book ai didi

IOS:在自定义 View Controller 和 View Controller 之间传回数据

转载 作者:行者123 更新时间:2023-11-29 12:56:27 25 4
gpt4 key购买 nike

<分区>

我有两个 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
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com