ALAsset
来源:互联网 发布:淘宝买xbox哪一家好 编辑:程序博客网 时间:2024/05/21 06:58
1、ALAsset,ALAssetsLibrary,ALAssetsgroup常见属性及用法
http://blog.csdn.net/shenjx1225/article/details/9293269
2、ALAssetsGroup详解
ALAssetsGroup类是系统用于映射相册资源中的每个相册,可以通过该类获取相册中的资源文件,并且能向相册中添加资源文件
//保存图片到系统默认的相册中,使用cgimageref的形式,并且选择图片以什么旋转方向的形式保存,并返回照片的url地址/* typedef enum { ALAssetOrientationUp, // default orientation ALAssetOrientationDown, // 180 deg rotation ALAssetOrientationLeft, // 90 deg CCW ALAssetOrientationRight, // 90 deg CW ALAssetOrientationUpMirrored, // as above but image mirrored along other axis. horizontal flip ALAssetOrientationDownMirrored, // horizontal flip ALAssetOrientationLeftMirrored, // vertical flip ALAssetOrientationRightMirrored, // vertical flip } ALAssetOrientation; */UIImage* image = [UIImage imageNamed:@"test.png"];[_library writeImageToSavedPhotosAlbum:[image CGImage] orientation:ALAssetOrientationLeft completionBlock:^(NSURL *assetURL, NSError *error) { NSLog(@"save image:%@",assetURL); //通过ALAssetsLibrary迭代取出所有相册 [_library enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop) { NSString* groupname = [group valueForProperty:ALAssetsGroupPropertyName]; //如果相册的名称是test的时候,对其进行操作 if ([groupname isEqualToString:@"test"]) { //设置相册组的筛选条件,ALAssetsFilter类表示筛选条件,allPhotos代表相册只包含相片,allVideos代表只包含视频,allAssets代表包含所有资源 [group setAssetsFilter:[ALAssetsFilter allPhotos]]; //通过刚保存的照片的url,把保存到默认相册的照片也保存到test相册中 [_library assetForURL:assetURL resultBlock:^(ALAsset *asset) { //添加资源到指定的相册 [group addAsset:asset]; //获取相册中一共的资源数量 int count = [group numberOfAssets]; NSLog(@"count:%d",count); dispatch_queue_t main = dispatch_get_main_queue(); dispatch_async(main, ^{ //获取相册的封面图片 CGImageRef poster = [group posterImage]; [imageView setImage:[UIImage imageWithCGImage:poster]]; }); //NSString *const ALAssetsGroupPropertyName; //NSString *const ALAssetsGroupPropertyType; //NSString *const ALAssetsGroupPropertyPersistentID; //NSString *const ALAssetsGroupPropertyURL; //查看相册的名字 NSLog(@"ALAssetsGroupPropertyName:%@",[group valueForProperty:ALAssetsGroupPropertyName]); //查看相册的类型 NSLog(@"ALAssetsGroupPropertyType:%@",[group valueForProperty:ALAssetsGroupPropertyType]); //查看相册的存储id NSLog(@"ALAssetsGroupPropertyPersistentID:%@",[group valueForProperty:ALAssetsGroupPropertyPersistentID]); //查看相册存储的位置地址 NSLog(@"ALAssetsGroupPropertyURL:%@",[group valueForProperty:ALAssetsGroupPropertyURL]); //按遍历顺序获取指定索引的资源,遍历顺序可以是先序或倒序 /* enum { NSEnumerationConcurrent = (1UL << 0), NSEnumerationReverse = (1UL << 1), }; typedef NSUInteger NSEnumerationOptions; */ [group enumerateAssetsAtIndexes:[NSIndexSet indexSetWithIndex:0] options:NSEnumerationConcurrent usingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) { }]; //按顺便遍历获取相册中所有的资源,index代表资源的索引,stop赋值为false时,会停止遍历 [group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) { }]; //按顺便遍历获取相册中所有的资源,遍历顺序可以是先序或倒序,index代表资源的索引,stop赋值为false时,会停止遍历 [group enumerateAssetsWithOptions:NSEnumerationReverse usingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) { }]; } failureBlock:^(NSError *error) { }]; } } failureBlock:^(NSError *error) { }];}];
0 0
- ALAsset
- ALAsset是什么?
- ALAsset类
- ALAsset和ALAssetRepresentation详解
- ALAsset和ALAssetRepresentation详解
- ALAsset和ALAssetRepresentation详解
- ALAsset和ALAssetRepresentation详解
- ALAsset和ALAssetRepresentation详解
- ALAsset和ALAssetRepresentation详解
- ALAsset和ALAssetRepresentation详解
- ALAsset 相册的使用
- ALAsset和ALAssetRepresentation详解
- ALAsset和ALAssetRepresentation详解
- ALAsset和ALAssetRepresentation详解
- ios ALAsset和ALAssetRepresentation详解
- 用ALAsset获取相册原图
- OC -- ALAsset和ALAssetRepresentation相册详解
- ALAssetsLibrary,ALAssetsGroup,ALAsset,ALAssetRepresentation用法详解
- msp430 串口接收程序处理
- latex 中文支持
- 【实用可测】C++ Https访问不安全证书服务器代码
- MVC框架详解,框架到底是什么?
- Linux中TCP连接过程状态简介
- ALAsset
- Java必备:基本Annotation
- 如何查看及修改oracle编码格式方法
- activiti中的activity
- wamp配置问题
- Android应用开发-小巫CSDN博客客户端之获取评论列表
- Eclipse下使用SVN版本控制
- php中iconv函数使用详解
- Android自动化测试(UiAutomator)简要介绍