views:

22

answers:

1

I'm using the UIImagePickerController to allow the user to select a photo from their library. I then want to assign the chosen image with this code;

  • (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary )info { UIImage image = [info objectForKey:UIImagePickerControllerOriginalImage]; [users_pic_ setImage:image]; [self dismissModalViewControllerAnimated:YES]; }

But the users pic never changes.

users_pic_ is defined as: UIImageView* user_pic_;

Anybody notice anything wrong? Thanks

A: 

use this code -

// make sure to allocate users_pic_

UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage]; 
users_pic_.image = image; 
[self dismissModalViewControllerAnimated:YES];
John Qualis
The problem turned was that the UIImageView was not properly initialized. I allocated in my viewDidLoad method (it was previously setup in Interface builder via a XIB file) and then the [users_pic_ setImage:image] worked.

related questions