How to show image from UIImagePickerController to another ViewController.xib?
I have “ViewController1”, and here I got this code:
- (IBAction)goCamera:(id)sender {
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
[picker setSourceType:UIImagePickerControllerSourceTypeCamera];
[self presentModalViewController:picker animated:YES];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissModalViewControllerAnimated:YES];
UIImageView *theimageView = [[UIImageView alloc]init];
theimageView.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
}
How can I go to “ViewController2” and to show taken photo there? I use ViewController1 to take a photo and I want to show this taken photo in ViewController2 where I got a UIImageView. Thanks a lot
The best approach is save the image within the app’s folders as soon as you’ve received the image.
This is important, because it helps with memory management.
You can let go of the image data, instead of passing it around the app.
I use code similar to the following:
Then in your other view controller, wherever you would expect to load the image (viewDidLoad, viewWillAppear or wherever) put:
Hope that helps