我的当前图像可以向后和向前滑动。所有图像都在名为pages的文件夹中。因此,当我在当前视图中时,我有一个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];
}
答案 0 :(得分:3)
将uiview绘制到上下文
UIGraphicsBeginImageContext(size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
并使用UIImageWriteToSavedPhotosAlbum(UIImage *image, id completionTarget, SEL completionSelector, void *contextInfo);
保存到相册