用法:
#import <AssetsLibrary/ALAssetsLibrary.h>
#import <AssetsLibrary/AssetsLibrary.h>
typedef void (^DoneHandler)(NSDictionary *ret);
- (void)get:(NSString *)key callback:(DoneHandler)handler {
  
 ALAssetsLibrary* assetslibrary = [[ALAssetsLibrary alloc] init];
  
 [assetslibrary assetForURL:[NSURL URLWithString:key] resultBlock:^(ALAsset *asset) {
  //NSLog(@"asset:%@",asset);
  UIImage *image = nil;
  image = [UIImage imageWithCGImage:[asset aspectRatioThumbnail]];
  image = [UIImage imageWithCGImage:[[asset defaultRepresentation] fullResolutionImage]];
  image = [UIImage imageWithCGImage:[[asset defaultRepresentation] fullScreenImage]];
        handler(@{@"image":image});
 } failureBlock:^(NSError *error) {
        handler(@{});
 }];
}
其中 key 是類似這樣:assets-library://asset/asset.JPG?id=xxx&ext=JPG。
沒有留言:
張貼留言