将图片保存在iPhone的相册中
来源:互联网 发布:软件测试行业方向 编辑:程序博客网 时间:2024/04/26 03:26
原文地址:http://blog.csdn.net/microchenhong/article/details/6524960
有时候你的应用需要将应用中的图片保存到用户iPhone或者iTouch的相册中。 可以使用UIKit的这个类方法来完成。
- void UIImageWriteToSavedPhotosAlbum (
- UIImage *image,
- id completionTarget,
- SEL completionSelector,
- void *contextInfo
- );
image
要保存到用户设备中的图片
completionTarget
当保存完成后,回调方法所在的对象
completionSelector
当保存完成后,所调用的回调方法。 形式如下:
- ( void ) image: ( UIImage *) image
didFinishSavingWithError: ( NSError *) error
contextInfo: ( void *) contextInfo;
didFinishSavingWithError: ( NSError *) error
contextInfo: ( void *) contextInfo;
contextInfo
可选的参数,保存了一个指向context数据的指针,它将传递给回调方法。
比如你可以这样来写一个存贮照片的方法:
// 要保存的图片
UIImage *img = [ UIImage imageNamed:@"ImageName.png" ] ;
// 保存图片到相册中
UIImageWriteToSavedPhotosAlbum( img, self, @selector (image:didFinishSavingWithError:contextInfo:) , nil ) ;
UIImage *img = [ UIImage imageNamed:@"ImageName.png" ] ;
// 保存图片到相册中
UIImageWriteToSavedPhotosAlbum( img, self, @selector (image:didFinishSavingWithError:contextInfo:) , nil ) ;
回调方法看起来可能是这样:
- - (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error
- contextInfo:(void *)contextInfo
- {
- // Was there an error?
- if (error != NULL)
- {
- // Show error message…
- }
- else // No errors
- {
- // Show message image successfully saved
- }
- }
保存当前视图:
#import <QuartzCore/QuartzCore.h>
UIGraphicsBeginImageContext(currentView.bounds .size ); //currentView 当前的 view
[currentView. layer renderInContext: UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, nil , nil , nil );
- 将图片保存在iPhone的相册中
- 将图片保存在iPhone的相册中
- 将图片保存在iPhone的相册中
- 将图片保存在iPhone的相册中
- 将图片保存在本地相册中
- 打开相机,并返回没有被压缩的图片,并且将图片保存在相册中
- 截屏,并将截取的图片保存到相册中
- 将UIImageView上的图片保存到相册中
- 将图片保存到相册中
- iPhone应用程序 将图片保存到相册实例
- iPhone应用程序 将图片保存到相册实例
- iOS 将图片保存到iPhone本地相册
- ios 调用系统相机,图库,相册。将照片保存在相册,保存图片在本地,UIImagePickerController
- 在相册查看保存的图片
- 将图片保存到相册
- 将图片保存到相册
- 将图片保存到相册
- iOS-将图片保存到照片相册中
- poj 1682
- hdoj2112
- 春季养生之道
- 图形学中矩阵作用
- JAVA字符串补零
- 将图片保存在iPhone的相册中
- C 中常见的编程错误
- Web页面的聚合技术
- LDD3源码分析之与硬件通信&中断处理
- 只有华强北才能拯救诺基亚?
- CKFinder2.1破解的方法(删除This is the demo version of CKFinder)
- Oracle to_char to_date to_num函数
- nfs:server is not responding,still trying 原因与解决方案
- debian下使用dpkg来安装/卸载deb包