我已经开发了ipad应用程序。其中我有下载照片选项。我需要在ipad照片文件夹中保存照片当我们点击下载按钮时。有谁可以帮我解决如何保存照片从ipad应用程序到ipad设备相册。
谢谢,Prabhas .
有一个最短的方法(在ios模拟器和ios设备上测试)
-
你可以使用这个函数:
UIImageWriteToSavedPhotosAlbum(UIImage *image, id completionTarget, SEL completionSelector, void *contextInfo);
你只需要completionTarget, completionSelector和contextInfo如果你想在图像保存完成时得到通知,否则你可以传入nil。
如果你想保存到一个自定义相册你可以通过一个很好的教程,我在
找到http://www.touch-code-magazine.com/ios5-saving-photos-in-custom-photo-album-category-for-download/
First Add #import <QuartzCore/QuartzCore.h>
-(void)buttonMethod:(UIButton *) Sender
{
UIGraphicsBeginImageContext(self.imageView.frame.size);
[self.imageView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *attachimage = [[UIImage alloc]initWithData:[NSData data]];
UIImage *viImage=UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
attachimage = viImage;
UIImageWriteToSavedPhotosAlbum(viImage, nil, nil, nil);
}