如何設置UICollectionViewCell作爲按鈕使用,該功能完成後也會重複使用。 我想用單元格作爲按鈕來添加來自我的照片庫的圖像。 代碼提取是我用來添加圖像的barbutton項目的功能。使用UICollectionViewCell作爲按鈕
- (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];
}
我的代碼提取物是從我ViewController.m文件,我做了一個cellbutton模型類。如何從那裏得到它 – 000