ELCImagePickerController 同时选择多张图片时,获取文件名称
2016-11-24 09:44
1116 查看
for (NSDictionary *dictin info) {
if ([dictobjectForKey:UIImagePickerControllerMediaType] ==ALAssetTypePhoto){
if ([dictobjectForKey:UIImagePickerControllerOriginalImage]){
UIImage* image=[dictobjectForKey:UIImagePickerControllerOriginalImage];
[images addObject:image];
//获取图片名称
__blockNSString *imageName = [NSStringnew];
ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset){
ALAssetRepresentation *representation = [myassetdefaultRepresentation];
imageName = [representation
filename];
NSLog(@"fileName : %@",imageName);
};
//注意这个地方,网上大多数用的是系统的类,单张选中,所以这个地方会是info,所以如果直接网上复制的代码,运行之后,会报错,需要改成dict
NSURL *imageURL = [dictvalueForKey:UIImagePickerControllerReferenceURL];
ALAssetsLibrary* assetslibrary = [[ALAssetsLibraryalloc]
init];
[assetslibrary assetForURL:imageURL
resultBlock:resultblock
failureBlock:nil];
[selfdismissViewControllerAnimated:YEScompletion:^{
//获取图片的类型前的名字,将字符串切割操作
NSString *imagePath = [[imageNamecomponentsSeparatedByString:@"."]
firstObject];
NSString *aPath=[NSStringstringWithFormat:@"%@/Documents/%@.jpg",
NSHomeDirectory(),imagePath];
NSData *imgData =UIImageJPEGRepresentation(image,0);
//将图片写入沙盒
[imgData writeToFile:aPathatomically:YES];
NSLog(@"path == %@ ==%@",imagePath,aPath);
}];
} else {
NSLog(@"UIImagePickerControllerReferenceURL = %@", dict);
}
} elseif ([dict
objectForKey:UIImagePickerControllerMediaType] ==ALAssetTypeVideo){
}
if ([dictobjectForKey:UIImagePickerControllerMediaType] ==ALAssetTypePhoto){
if ([dictobjectForKey:UIImagePickerControllerOriginalImage]){
UIImage* image=[dictobjectForKey:UIImagePickerControllerOriginalImage];
[images addObject:image];
//获取图片名称
__blockNSString *imageName = [NSStringnew];
ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset){
ALAssetRepresentation *representation = [myassetdefaultRepresentation];
imageName = [representation
filename];
NSLog(@"fileName : %@",imageName);
};
//注意这个地方,网上大多数用的是系统的类,单张选中,所以这个地方会是info,所以如果直接网上复制的代码,运行之后,会报错,需要改成dict
NSURL *imageURL = [dictvalueForKey:UIImagePickerControllerReferenceURL];
ALAssetsLibrary* assetslibrary = [[ALAssetsLibraryalloc]
init];
[assetslibrary assetForURL:imageURL
resultBlock:resultblock
failureBlock:nil];
[selfdismissViewControllerAnimated:YEScompletion:^{
//获取图片的类型前的名字,将字符串切割操作
NSString *imagePath = [[imageNamecomponentsSeparatedByString:@"."]
firstObject];
NSString *aPath=[NSStringstringWithFormat:@"%@/Documents/%@.jpg",
NSHomeDirectory(),imagePath];
NSData *imgData =UIImageJPEGRepresentation(image,0);
//将图片写入沙盒
[imgData writeToFile:aPathatomically:YES];
NSLog(@"path == %@ ==%@",imagePath,aPath);
}];
} else {
NSLog(@"UIImagePickerControllerReferenceURL = %@", dict);
}
} elseif ([dict
objectForKey:UIImagePickerControllerMediaType] ==ALAssetTypeVideo){
}
相关文章推荐
- ELCImagePickerController 选择图片
- 不使用UIImagePickerControllerOriginalImage获取相册图片
- 获取sd卡中的图片URL并显示,同时使用ImageView把选择的图片展现出来
- Cordova各个插件使用介绍系列(三)—$cordovaImagePicker从手机图库选择多张图片
- 不使用UIImagePickerControllerOriginalImage获取相册图片
- Cordova各个插件使用介绍系列(三)—$cordovaImagePicker从手机图库选择多张图片
- imagePickerController 获取图片的拍照时间等信息
- 不使用UIImagePickerControllerOriginalImage获取相册图片
- Cordova各个插件使用介绍系列(三)—$cordovaImagePicker从手机图库选择多张图片
- ios 使用UIImagePickerController 打开图片库和相机选择图片修改头像(iphone版本)
- 如何在ImagePickerController中只显示图片或者视频?(既视频和图片的筛选)
- UIImagePickerController(获取相册图片,打开相机)
- UIImagePickerController选择图片发送后旋转90度的问题
- 利用UIImagePickerController或者利用UIKit的 UIGraphicsBeginImageContext保存图片
- 临时解决UIImagePickerController在可编辑模式下选择相册图片后不能上移的bug
- UIImagePickerController获取图片名
- 【Android_Image】选择相册中的图片,并获取图片的path
- 【学习ios之路:UI系列】获取通过UIImagePackerController获取的系统相册图片的名称信息及保存系统相册到本地
- php中使用getimagesize获取图片、flash等文件的尺寸信息实例
- 从指定网址下载文件 并读出其内容 && 从网上下载文件放在本地&&从网上获取图片设在imageView里