簡體   English   中英

iphone sdk如何從照片庫中獲取完整的圖像?

[英]iphone sdk how to get complete images from photo library?

嗨我想要圖像保存在照片庫中。使用斷言庫我可以獲得存儲在照片庫中的完整圖像。如果是的話,任何人都可以告訴我代碼。謝謝提前。

超級容易!

UIImagePickerController *imagePicker = [[UIImagePickerController     alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

[imagePicker setDelegate:self];
[self presentModalViewController:imagePicker animated:YES];

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info 
{
    [picker dismissModalViewControllerAnimated:YES];
    [picker release];

    // Edited image works great (if you allowed editing)
    //myUIImageView.image = [info objectForKey:UIImagePickerControllerEditedImage];
    // AND the original image works great
    //myUIImageView.image = [info objectForKey:UIImagePickerControllerOriginalImage];
    // AND do whatever you want with it, (NSDictionary *)info is fine now
    //UIImage *myImage = [info objectForKey:UIImagePickerControllerEditedImage];

    UIImage *image =  [info objectForKey:UIImagePickerControllerOriginalImage];

    [customImageView setImage:image]; 

    customImageView.contentMode = UIViewContentModeScaleAspectFill;
}

從stackoverflow獲取此代碼,沒有保存URL,抱歉。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM