将图片保存在本地相册中
2014-03-23 22:04
330 查看
在一个视图中有一个UIImageView,当单击此UIImageView,将UIImageView中的UIImage所代表的图片保存到PhotoAlbum中。
UIImageWriteToSavedPhotosAlbum是UIKit框架中的一个函数。
这里说一下后面三个参数的含义:
void UIImageWriteToSavedPhotosAlbum(
UIImage *image,
id completionTarget,
SEL completionSelector,
void *contextInfo
);
id是target对象,sel是selector,即target对象上的方法名,contextInfo是任意指针,会传递到selector定义的方法上。一般是当完成后调用方法时使用,或者在完成时出错的处理。
imageView =[[UIImageView alloc]initWithFrame:self.view.bounds]; imageView.image =[UIImage imageNamed:@"1.jpg"]; [self.view addSubview:imageView]; [imageView release];
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch =[touches anyObject]; if ([touch tapCount]==1) { UIImageWriteToSavedPhotosAlbum(imageView.image, nil, nil, nil); UIAlertView *alert =[[UIAlertView alloc]initWithTitle:@"存储照片成功" message:@"您已将照片存储于图片库中,打开照片程序即可查看。" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; [alert release]; } }
UIImageWriteToSavedPhotosAlbum是UIKit框架中的一个函数。
这里说一下后面三个参数的含义:
void UIImageWriteToSavedPhotosAlbum(
UIImage *image,
id completionTarget,
SEL completionSelector,
void *contextInfo
);
id是target对象,sel是selector,即target对象上的方法名,contextInfo是任意指针,会传递到selector定义的方法上。一般是当完成后调用方法时使用,或者在完成时出错的处理。
相关文章推荐
- Android实现拍照,以及从相册选择图片裁剪功能同时保存在本地
- android安卓调用相册及相机并将图片保存本地
- 将相机/相册的图片保存到本地沙盒
- ios uiwebview 长按图片,保存到本地相册
- 截取手机屏幕中某个View的图像,并以图片形式保存到本地相册
- android保存图片到本地并可以在相册中显示出来
- 基于Android实现保存图片到本地并可以在相册中显示出来
- 保存图片到本地相册
- Android图片保存在本地相册
- iOS从本地相册选取图片, 把图片保存到本地相册
- 长按 WebView 页面图片弹出对话框可以选择保存长按的图片到本地相册
- 微信小程序导出当前画布指定区域的内容并生成图片保存到本地相册(canvas)
- iOS8之后, 保存图片到本地相册, 避免重复保存同一张
- imageView图片保存到本地和相册
- 安卓开发关于图片保存到本地相册并显示功能
- android相册拍照保存图片到本地
- 保存图片到本地相册
- 保存图片到本地,并及时在系统相册更新
- Android图片保存在本地相册
- imageLoader保存图片到本地相册