原文地址:http://blog.liming.it/?p=90
第一步:给项目的 TARGETS -> Build Phases -> Link Binary With Libraries 增加框架链接 AssetsLibrary.Framework
第二步:文件中引入:
#import <AssetsLibrary/AssetsLibrary.h>
第三步:相册选择图片的回调方法 imagePickerController:didFinishPickingMediaWithInfo: 中,增加如下代码:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info;{// get the ref urlNSURL *refURL = [info valueForKey:UIImagePickerControllerReferenceURL];// define the block to call when we get the asset based on the url (below)ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *imageAsset){ALAssetRepresentation *imageRep = [imageAsset defaultRepresentation];NSLog(@"[imageRep filename] : %@", [imageRep filename]);};// get the asset library and fetch the asset based on the ref url (pass in block above)ALAssetsLibrary* assetslibrary = [[ALAssetsLibrary alloc] init];[assetslibrary assetForURL:refURL resultBlock:resultblock failureBlock:nil];...}
本文详细介绍了如何在iOS应用中通过AssetsLibrary框架从相册选择图片,并解析了关键步骤及回调方法的实现。
431

被折叠的 条评论
为什么被折叠?



