如何獲取圖像路徑從照片庫以及如何從 iphone 在照片庫中檢索圖像?


 

我是新 iphone。在我小的應用程序,如何獲取圖像路徑從照片庫。下面的代碼獲取圖像並放在 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) ;它顯示"圖像路徑 ="在控制台中。如何獲得它的路徑,以及如何從照片庫中檢索的照片。任何機構幫助我。先謝謝了。

 

 

回答 #1

UIImagePickerControllerOriginalImage僅返回的圖像數據,根本沒有提到其本地存儲。我自己沒有用,但我猜你所尋找的

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

至少,這是我知道的檢索任何 URL 的唯一方法。

若要檢索圖像,看一看這個問題。但也請記住,您已經使用檢索的圖像,

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

所以問自己,是否你真的需要這樣。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM