我需要一张一张地捕获多张图像并将它们存储在一个数组中,在集合视图中显示存储的图像,然后将它们上传到服务器。
我对这个概念进行了很多搜索,但这些解决方案都不适合我,数组为空。
我尝试了以下代码:
- (IBAction)CaptureClicked:(id)sender {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:picker animated:YES completion:NULL];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[picker dismissViewControllerAnimated:YES completion:NULL];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
if (info[UIImagePickerControllerMediaType] == (NSString *) kUTTypeImage) {
[self.videoController.view removeFromSuperview];
UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
self->ImageView.image = chosenImage;
[picker dismissViewControllerAnimated:YES completion:NULL];
NSData *imageData =[NSData dataWithData:UIImagePNGRepresentation(chosenImage)];
[imageArray addObject:imageData];
[_ImageCollectionVIew reloadData];
}