2012-02-11 101 views

回答

3

超級簡單!

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; 
} 

得到了計算器這個代碼,沒有保存URL,對不起。

相關問題