先看文档:

1。保存图片

UIImageWriteToSavedPhotosAlbum

Adds the specified image to the user’s Camera Roll album.

void UIImageWriteToSavedPhotosAlbum (

UIImage  *image,

id       completionTarget,

SEL      completionSelector,

void     *contextInfo

);

Parameters

image

The image to write to the Camera Roll album.

completionTarget

Optionally, the object whose selector should be called after the image has been written to the Camera Roll album.

completionSelector

The method selector, of the completionTarget object, to call. This optional method should conform to the following signature:

- (void)               image: (UIImage *) image

didFinishSavingWithError: (NSError *) error

contextInfo: (void *) contextInfo;

contextInfo

An optional pointer to any context-specific data that you want passed to the completion selector.

Discussion

When used with an image picker controller, you would typically call this function within yourimagePickerController:didFinishPickingMediaWithInfo: delegate method implementation.

The use of the completionTarget, completionSelector, and contextInfo parameters is optional and necessary only if you want to be notified asynchronously when the function finishes writing the image to the user’s Camera Roll or Saved Photos album. If you do not want to be notified, passnil for these parameters.

When used on an iOS device without a camera, this method adds the image to the Saved Photos album rather than to the Camera Roll album.

Availability

  • Available in iOS 2.0 and later.

See Also

  • UISaveVideoAtPathToSavedPhotosAlbum

Declared In

UIImagePickerController.h

说明:后面三个参数是可选的。如果需要在图片保存成功后进行异步的通知,则后面三个参数是必需的。否则,传递nil。

不太明白 Saved Photos album与Camera Roll album间的区别。。。图片库与相机胶卷。。。感觉在机子里是一回事。

拍照时点击左下角的button会切换到图片库啊???

下面的保存视频的方法与保存图片的方法非常类似,用法基本一样。

下面贴点代码:

(1)最常用的方法

UIImageWriteToSavedPhotosAlbum(UIImage *image, id completionTarget, SEL completionSelector, void *contextInfo);

(2)用AVFoundation库

There`s much more fast than UIImageWriteToSavedPhotosAlbum way to do it using iOS 4.0+ AVFoundation framework

   ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];[library writeImageToSavedPhotosAlbum:[image CGImage] orientation:(ALAssetOrientation)[image imageOrientation] completionBlock:^(NSURL *assetURL, NSError *error){if (error) {// TODO: error handling} else {// TODO: success handling}
}];
[library release];

主要是以上两种保存图片的方法

具体点:

    //in the .h file put:NSMutableArray *myPhotoArray;///then in the .m- (void) viewDidLoad {myPhotoArray = [[NSMutableArray alloc]init];}//However Your getting images- (void) someOtherMethod { UIImage *someImage = [your prefered method of using this];
[myPhotoArray addObject:someImage];}-(void) saveMePlease {//Loop through the array here
for (int i=0:i<[myPhotoArray count]:i++){NSString *file = [myPhotoArray objectAtIndex:i];NSString *path = [get the path of the image like you would in DOCS FOLDER or whatever];NSString *imagePath = [path stringByAppendingString:file];UIImage *image = [[[UIImage alloc] initWithContentsOfFile:imagePath]autorelease];//Now it will do this for each photo in the arrayUIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);}
}

2。保存视频

UISaveVideoAtPathToSavedPhotosAlbum

Adds the movie at the specified path to the user’s Camera Roll album.

void UISaveVideoAtPathToSavedPhotosAlbum (

NSString  *videoPath,

id        completionTarget,

SEL       completionSelector,

void      *contextInfo

);

Parameters

videoPath

The filesystem path to the movie file you want to save to the Camera Roll album.

completionTarget

Optionally, the object whose selector should be called after the movie has been written to the Camera Roll album.

completionSelector

The method selector, of the completionTarget object, to call. This optional method should conform to the following signature:

- (void)               video: (NSString *) videoPath

didFinishSavingWithError: (NSError *) error

contextInfo: (void *) contextInfo;

contextInfo

An optional pointer to any context-specific data that you want passed to the completion selector.

Discussion

When used with an image picker controller, you would typically call this function within yourimagePickerController:didFinishPickingMediaWithInfo: delegate method implementation.

Before calling this function, call theUIVideoAtPathIsCompatibleWithSavedPhotosAlbum function to determine if it is possible to save movies to the Camera Roll album. For a code example, refer toCamera Programming Topics for iOS.

The use of the completionTarget, completionSelector, and contextInfo parameters is optional and necessary only if you want to be notified asynchronously when the function finishes writing the movie to the user’s Camera Roll or Saved Photos album. If you do not want to be notified, passnil for these parameters.

When used on an iOS device without a camera, this method adds the movie to the Saved Photos album rather than to the Camera Roll album.

Availability

  • Available in iOS 3.1 and later.

See Also

  • UIImageWriteToSavedPhotosAlbum
  • UIVideoAtPathIsCompatibleWithSavedPhotosAlbum

Declared In

UIImagePickerController.h

保存图片到图片库的方法相关推荐

  1. 调用照相机与图片库并实现保存图片到图片库

    传智播客ios7-仿照微信发送图片调用照相机与图片库并实现保存图片到图片库 #import <UIKit/UIKit.h>// 添加委托 @interface ViewController ...

  2. delphi xe 保存图片到JPG的方法 BMP转JPG

    FireMonkey 保存图片到JPG的方法 BMP转JPG 习惯VCL的做法了,到了FireMonkey里面,好像查不到单独的JPEG单元了,不少朋友就郁闷如何处理JPG了,这么大件事,不可能没有处 ...

  3. Typora等markdown笔记软件图片链接失效的问题解决办法,图片的相对路径、绝对路径的设置,图片上传到图床的方法

    文章目录 -遇到的问题:Typora编辑MD文档,图片失效的问题解决 -解决的方法: 方法一:本地图片,使用相对路径,并将图片放在和md文件的同一目录下 步骤1.Typora的图片根目录设置 步骤2. ...

  4. Matlab保存图片的几种方法

    写在前面:本文系作者原创,转载或引用请注明文章出处,多谢! Matlab中保存图片有很多函数可以用到,本文将简单总结三种保存图像的方法,其他的日后补充. 1.保存一幅经过处理的图像,又不希望损失其分辨 ...

  5. FireMonkey 保存图片到JPG的方法 BMP转JPG

    习惯VCL的做法了,到了FireMonkey里面,好像查不到单独的JPEG单元了,不少朋友就郁闷如何处理JPG了,这么大件事,不可能没有处理方法的,具体就请看代码: uses FMX.Surfaces ...

  6. Python 保存图片的两种方法

    有时我们需要保存我们的图片,那我们可以怎么保存呢? 可参考下列保存的两种方法: 第一种:cv2.imwrite() 示例: # 方法一 : import cv2 cv2.imwrite("i ...

  7. python读取和保存图片的三种方法

    python读取和保存图片 opencv import cv2 #load img = cv2.imread('0.png') #show cv.imshow('title', img) #save ...

  8. python保存图片的三种方法

    有时候将图片保存到本地会发现颜色与原来不一致,有的变成相反的颜色了 .针对这个问题,我试了好多方法,原理不大清楚.但多换一种保存方式就OK了. 常用的有三种: 1.PIL # 需要导入的库 impor ...

  9. B2G系统简介(部分资料来源于网上)

    一.      B2G介绍 B2G是"Boot To Gecko"的缩写,是Mozilla公司基于Web标准开发的完全开放的移动操作系统,从系统本身到应用程序完全由HTML5.CS ...

最新文章

  1. 【OpenCV3】图像通道分离与合并——cv::split()与cv::merge()详解
  2. python网络编程视频教程_Java网络开发视频教程 – 一站式学习Java网络编程视频教程 全面理解BIO(无密)...
  3. python人工智能——机器学习——数据的划分和介绍
  4. thread.sleep是让哪个线程休眠_Java多线程:多线程基础知识
  5. razor页面跳转_如何在Blazor中使用Razor页面创建单页应用程序
  6. BootstrapTable冻结表头(一)
  7. BUG搬运工:CSCvp31778-3802 apsw_watchdog: WARNING: System memory is running low
  8. ajax没效果,ajax没有效果
  9. 手把手FFmpeg入门——视频解码+解封装
  10. 小白如何快速学会C++?
  11. MacOS平台上编译 hadoop 3.1.2 源码
  12. mkdir用大括号同时建立多个同级和下级目录
  13. 整理一下自动生成代码的软件
  14. xmapp下mysql的密码更改
  15. 高级计量经济学及Stata应用 第2版 陈强+stata十八讲+应用STATA做统计分析
  16. Mac OS 关闭系统更新提示小红点
  17. Robocup新手指南
  18. 【JAVA8】快速理解Consumer、Supplier、Predicate与Function
  19. nslookup命令反解ip_PING、TRACERT、NSLOOKUP命令的使用方法
  20. 无法连接到服务器的错误解决方案

热门文章

  1. sketchup/su模型导入到Unity3D
  2. 迅捷电子相册快速生成视频的方法--win10专业版
  3. 计算机主板按那三种方法分类,如何查看计算机主板型号,几秒钟即可了解三种方法...
  4. 汇众智,奔涌向前赢未来 | 2023开放原子全球开源峰会 OpenAtom openEuler 分论坛即将启幕
  5. 智能家居“火”烧全球 芯片巨头鏖战、鹿死谁手?
  6. 音频合并无缝衔接怎么弄?这篇文章教会你
  7. php制作门户网站,自己设计制作门户网站模板风格【PHP小白搭建的】
  8. 【Unity】多方式批量修改Tag值
  9. 通过Excel对人力资源考勤评估
  10. 14. Perl 正则表达式-正则匹配