![](/img/trans.png)
[英]iOS : Saving from current UIImageView to Photo Album Failed - Unable to save to photo album
[英]iOS : How to save current image from my current UIView to photo album? I'm stuck with UIImageWriteToSavedPhotosAlbum
我的当前图像可以前后滑动。 所有图像都在一个名为页面的文件夹中。 因此,当我处于当前视图中时,我有一个IBAction将当前图像保存到相册中。 如何执行该任务? 我已经研究过了,但是我不知道如何开始,我陷入了困境。
M档:
我定义了UIImage.h
void UIImageWriteToSavedPhotosAlbum (
UIImage *image,
);
- (IBAction)saveMe{
[UIImageWriteToSavedPhotosAlbum];
}
我的修正代码:
-(IBAction) saveToPhotoAlbum{
}
- (void) imageViewController:(UIImageView *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = //i have 6 current UIImageview on my current main view. How do I get stated?
UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
[picker release];
}
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
{
UIAlertView *alert;
if (error)
alert = [[UIAlertView alloc] initWithTitle:@"Error"
message:@"Unable to save image to Photo Album."
delegate:self cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
else
alert = [[UIAlertView alloc] initWithTitle:@"Success"
message:@"Image saved to Photo Album."
delegate:self cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alert show];
[alert release];
}
根据上下文绘制uiview
UIGraphicsBeginImageContext(size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
并使用UIImageWriteToSavedPhotosAlbum(UIImage *image, id completionTarget, SEL completionSelector, void *contextInfo);
用于保存到相册
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.