获取UIImagePickerController选中图片名称

#pragma mark UIImagePickerControllerDelegate

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{

NSURL *imageURL = [info valueForKey:UIImagePickerControllerReferenceURL];

ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset)

{

ALAssetRepresentation *representation = [myasset defaultRepresentation];

_picName = [representation filename];

NSLog(@"fileName : %@",_picName);

};

ALAssetsLibrary* assetslibrary = [[ALAssetsLibrary alloc] init];

[assetslibrary assetForURL:imageURL

resultBlock:resultblock

failureBlock:nil];

[picker dismissViewControllerAnimated:YES completion:^{

UIImage *editedImage, *originalImage;

editedImage = [info objectForKey:UIImagePickerControllerEditedImage];

_headImg.image=editedImage;

// 保存原图片到相册中

if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {

originalImage = [info objectForKey:UIImagePickerControllerOriginalImage];

UIImageWriteToSavedPhotosAlbum(originalImage, self, nil, NULL);

}

}];

}

注释:再工程中导入类库


获取UIImagePickerController选中图片名称_第1张图片

再次:导入所需头文件:


获取UIImagePickerController选中图片名称_第2张图片

你可能感兴趣的:(获取UIImagePickerController选中图片名称)