gpt4 book ai didi

ios - 使用 UICollectionViewCell 作为按钮

转载 作者:行者123 更新时间:2023-11-28 19:53:34 26 4
gpt4 key购买 nike

如何将 UICollectionViewCell 设置为用作按钮,当函数完成时它也会自行重复。我想将单元格用作按钮来从我的照片库中添加图像。代码摘录是我用来添加图片的barbutton项的功能。

- (IBAction)buttonTapped:(id)sender {
_picker = [[UIImagePickerController alloc] init];
_picker.delegate = self;
_picker.allowsEditing = NO;
_picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:_picker animated:YES completion:nil];
}



- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {
[_images addObject:image];
[self saveNewImageToDb:image];
[self dismissViewControllerAnimated:_picker completion:^{
[_collectionView reloadData];
}];
}




-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[self dismissViewControllerAnimated:_picker completion:nil];
}

最佳答案

你可以实现这个功能:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
// something you do as function "buttonTapped"
}

关于ios - 使用 UICollectionViewCell 作为按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27834775/

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