Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/109.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在iOS中关闭UICollectionView后保存图像_Ios_Objective C_Uiimagepickercontroller_Uicollectionview_Popover - Fatal编程技术网

在iOS中关闭UICollectionView后保存图像

在iOS中关闭UICollectionView后保存图像,ios,objective-c,uiimagepickercontroller,uicollectionview,popover,Ios,Objective C,Uiimagepickercontroller,Uicollectionview,Popover,我有一个UICollectionView,它有一个按钮,可以打开相机并将图像保存到UICollectionView - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo{ [self.images addObject:image]; //NSLog([NSString

我有一个UICollectionView,它有一个按钮,可以打开相机并将图像保存到UICollectionView

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo{
[self.images addObject:image];
//NSLog([NSString stringWithFormat:@"%d",[self.images count]]);
NSIndexPath *ip = [NSIndexPath indexPathForRow:[self.images count] inSection:0];
[picker dismissViewControllerAnimated:YES completion:nil];
[self.galleryView reloadData];
IDMPhoto *photo;

photo = [IDMPhoto photoWithImage:image];
photo.caption = @"Sample";
[photos addObject:photo];
}

现在我的问题是我有一个“完成”按钮,如何将图像保存到gallery并添加(文件名+编号)。顺便说一句,UICollectionView嵌入到PopOver中

最后,当我打开UICollectionView时,它是否可能检索gallery中的图像


我希望你能帮助我……谢谢!:D

如果您的“完成”按钮也嵌入到popover中(我假设是这样),只需使用委派并在popover
ViewController
界面文件中创建协议即可。让演示
ViewController
成为该协议的代理,然后在完成图像拾取后启动该代理方法

大概是这样的:

@protocol MyCollectionImagePickerDelegate
    -(void)doneSelectingImage:(UIImage *)image;
@end

@interface MyCollectionViewPopoverController : UIViewController {
    __unsafe_unretained id <MyCollectionImagePickerDelegate> _delegate;
}

@property (nonatomic, assign) id <MyCollectionImagePickerDelegate> delegate;

在您的演示VC类中,您只需实现该方法,并对基础集合执行您需要的操作(
NSArray
我假定)。

您好,谢谢您的建议,我将首先尝试:)我会让您知道它是否有效
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo { 
    [_delegate doneSelectingImage:image];
}