ALAssetsLibrary 提供了访问iOS设备下照片应用下所有照片和视频的接口.
从 ALAssetsLibrary 中可读取所有的相册数据,即 ALAssetsGroup 对象列表;
从每个 ALAssetsGroup 中可获取到其中包含的照片或视频列表,即 ALAsset 对象列表.
其层次关系为 ALAssetsLibrary -> ALAssetsGroup -> ALAsset -> ALAssetRepresentation.
1. 每个 ALAsset 可能有多个representations表示, 即ALAssetRepresentation 对象:
2. 使用其defaultRepresentation 方法可获得其默认representations,
3. 使用[asset valueForProperty: ALAssetPropertyRepresentations ]可获取其所有representations的 UTI 数组。
4. 从ALAsset对象可获取缩略图 thumbnail 或 aspectRatioThumbnail ;
5. 从 ALAssetRepresentation 对象可获取全尺寸图片(fullResolutionImage), 全屏图片(fullScreenImage)及图片的各种属性: orientation, dimensions, scale, url, metadata等。
如下代码及其相关注释:
#import <AssetsLibrary/AssetsLibrary.h>
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 64, self.view.frame.size.width - 20,