如何从照片库获取图像路径以及如何从iphone中的照片库中检索图像? [英] How to get image path from photo library and how to retrieve the image from photo library in iphone?

查看:150
本文介绍了如何从照片库获取图像路径以及如何从iphone中的照片库中检索图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是iphone的新手。在我的小应用程序中,如何从照片库获取图像路径。我使用以下代码来获取图像并放置在imageview中。

I'm new to iphone. In my small application, how to get image path from photo library. I use this following code to getting images and placed in imageview.

-(IBAction) selectimage
{
UIImagePickerController *picker=[[UIImagePickerController alloc] init];
picker.delegate=self;
picker.sourceType=UIImagePickerControllerSourceTypeSavedPhotosAlbum;
[self presentModalViewController:picker animated:YES];
[picker release];
}
-(void) imagePickerController:(UIImagePickerController *)UIPicker didFinishPickingMediaWithInfo:(NSDictionary *) info
{
[UIPicker dismissModalViewControllerAnimated:YES];
imageview.image=[info objectForKey:"UIImagePickerControllerOriginalImage"];
    NSLog("Image Path=%@",imageview.image);
}

成功放置到Imageview。但我不能得到它的imagepath。我正在使用nslog(%@,imageview.image);它在控制台中显示Image Path =。
如何获取其路径以及如何从照片库中检索照片。任何身体帮助我。在此先感谢。

Its succefully placed to Imageview. But i cant get its imagepath. I'm using nslog("%@",imageview.image); it shows "Image Path=" in console. How can i get its path and how to retrieve photos from photo library. Any body help me. Thanks in advance.

推荐答案

UIImagePickerControllerOriginalImage 仅返回图片的数据,没有参考其本地存储。我自己没有用过,但我想你要找的是

UIImagePickerControllerOriginalImage returns only the image's data, with no reference to its local storage. I haven't used it myself but I guess what you are looking for is

NSURL* localUrl = (NSURL *)[info valueForKey:UIImagePickerControllerReferenceURL];

至少,这是我知道检索任何网址的唯一方法。

At least, it's the only way I know of to retrieve any URL.

要检索图像,请查看这个问题。但请记住,你已经用

To retrieve the image, have a look at this question. But also keep in mind, that you already have the image retrieved with

UIImage* image=(UIImage*)[info objectForKey:@"UIImagePickerControllerOriginalImage"];

所以问问自己是否真的需要这个。

so ask yourself if you really need this.

这篇关于如何从照片库获取图像路径以及如何从iphone中的照片库中检索图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆