循环调用方法,已达到保存全部图片的效果
2018-10-26 本文已影响11人
虫yu
-(void)downImage:(UIButton*)sender{
for(UIView *subview in [imgCollectoin subviews]){
NSLog(@"subview=%@",subview);
if([subview isKindOfClass:[UIButton class]]){
UIButton* imgView = (UIButton*)subview;
[imgArray addObject:imgView.imageView.image];
NSLog(@"%@",imgView.imageView.image);
}
}
[UIView dd_showMessage:@"图片保存成功"];
[self saveNextPhoto];
}
-(void)saveNextPhoto{
if(imgArray.count>0){
UIImage *image=[imgArray objectAtIndex:0];
UIImageWriteToSavedPhotosAlbum(image, self, @selector(savedPhotoImage:didFinishSavingWithError:contextInfo:), nil);
}else{
}
}
-(void)savedPhotoImage:(UIImage*)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo{
if(error){
}else{
[imgArray removeObjectAtIndex:0];
}
[self saveNextPhoto];
}