如何将图片保存至自定义分组
一般我们照片存储都是直接存储在相机胶卷中,调用下面的方法就可以了:
[plain]
void UIImageWriteToSavedPhotosAlbum (
UIImage *image,
id completionTarget,
SEL completionSelector,
void *contextInfo
);
void UIImageWriteToSavedPhotosAlbum (
UIImage *image,
id completionTarget,
SEL completionSelector,
void *contextInfo
);
但是如果我们想将图片存储到自定义的分组该怎么做呢,我查了一下ALAssetsLibrary的文档,发现没有相应的方法,好吧,google一下,发现了一篇文章:点击打开链接。
作者的解决思路如下:
1.将图片先保存到相机胶卷中;
2.在相机胶卷中找到这个图片所创建的AlAsset;
3.将此AlAsset添加到你需要存放的自定义分组中。
主要代码如下所示,注释也很清楚了:
[plain]
-(void)saveImage:(UIImage*)image toAlbum:(NSString*)albumName withCompletionBlock:(SaveImageCompletion)completionBlock
{
//write the image data to the assets library (camera roll)
[self writeImageToSavedPhotosAlbum:image.CGImage orientation:(ALAssetOrientation)image.imageOrientation
completionBlock:^(NSURL* assetURL, NSError* error) {
//error handling
if (error!=nil) {
completionBlock(error);
return;
}
//add the asset to the custom photo album
相关新闻>>
- 发表评论
-
- 最新评论 进入详细评论页>>
今日头条
更多>>您可能感兴趣的文章
- iOS文件存磁盘的设想
- ios 时间定时器 NSTimer应用demo
- 深入理解iPhone静态库(手把手教你iphone开发
- Cocoa Core Competencies 的Object creation 和IOS面试题示例
- (iOS-iap防护)验证用户付费收据,拒绝iap
- iphone-使用TextField及关闭键盘(useing TextField for in
- ios 关于UITableView UITableViewCellAccessoryCheckmark 混乱的
- iphone开发基础三和c语言混编
- iPhone开发 文件的增加删除查询
- iPhone开发 调用阿asp.net程序的webservice