你好每一個人請幫助我在這: 因爲我在這UICollectionView
UICollectionView
我加入圖像,我想刪除按鈕點擊一個特定的圖像。 我想要刪除的圖像上有關閉按鈕。 我如何執行此任務。 注: 1)請在幫助之前查看圖像一次。 2)請參閱添加圖像的代碼。如何刪除特定的UICollectionViewCell圖像。在按下特定圖像上的按鈕
圖片: My Image
//**** For image work ****
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *ident = @"Cell";
OwnerPropertyCollectionViewCell *cell = (OwnerPropertyCollectionViewCell*)[collectionView dequeueReusableCellWithReuseIdentifier:ident forIndexPath:indexPath];
imgView = (UIImageView*)[cell viewWithTag:100];
if (indexPath.row ==0) {
cell.Imgprofile_pic.image = [UIImage imageNamed:[imgArray objectAtIndex:indexPath.row]];
cell.btnImageCancel.image = [UIImage imageNamed:@"add"];
UITapGestureRecognizer *reconizer = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(addphoto:)];
[cell addGestureRecognizer:reconizer];
}
else {
// get image not name
cell.Imgprofile_pic.image = [imgArray objectAtIndex:indexPath.row];
cell.btnImageCancel.image = [UIImage imageNamed:@"close"];
}
return cell;
}
// To add image:
-(void)addphoto:(UITapGestureRecognizer*)reconizer
{
imageHelper = [UIImagePickerHelper new];
[imageHelper imagePickerInViewController:self WithSuccess:^(UIImage *image) {
imgView.image = image;
[imgArray addObject:image];
[self.collectionView reloadData];
} failure:^(NSError *error) {
}];
NSLog(@"Image added successfully");
}
// What to code for delete image:
- (IBAction)btnCancelButtonAction:(id)sender {
NSLog(@"Delete button pressed");
}
謝謝你,但我仍然有點困惑。但我正在努力,謝謝。 – raj