标签:
通过IUImagePickerController方法获取系统的相册,而想要得到从系统相册得到的图片的信息需要以下几步:
1:获得从UIImagePicker选择的照片的Assert;
2:得到Assert的ALAssertRepresentation;
3:ALAssertRepresentation有个filename的属性
代码具体如下:
该方法是UIImagePickerController中的代理中的方法
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { NSURL *imageURL = [info valueForKey:UIImagePickerControllerReferenceURL]; ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset) { ALAssetRepresentation *representation = [myasset defaultRepresentation]; NSString *fileName = [representation filename]; NSLog(@"fileName : %@",fileName); }; ALAssetsLibrary* assetslibrary = [[[ALAssetsLibrary alloc] init] autorelease]; [assetslibrary assetForURL:imageURL resultBlock:resultblock failureBlock:nil]; }注:想要用到以上操作,需要引入以下的内容
#import <AssetsLibrary/ALAsset.h> #import <AssetsLibrary/ALAssetsLibrary.h> #import <AssetsLibrary/ALAssetsGroup.h> #import <AssetsLibrary/ALAssetRepresentation.h>如下效果:
原文地址:点击
【学习ios之路:UI系列】获取通过UIImagePackerController获取的系统相册图片的名称信息
标签:
原文地址:http://blog.csdn.net/zfx5130/article/details/43114953