Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8983325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:48:51+00:00 2026-06-15T20:48:51+00:00

How to show image from UIImagePickerController to another ViewController.xib? I have ViewController1, and here

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T20:48:53+00:00Added an answer on June 15, 2026 at 8:48 pm

    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:

    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    
        UIImage *originalImage, *editedImage, *imageToSave;
        editedImage = (UIImage *) [info objectForKey:
                                   UIImagePickerControllerEditedImage];
        originalImage = (UIImage *) [info objectForKey:
                                     UIImagePickerControllerOriginalImage];
        imageToSave = (editedImage!=nil ? editedImage : originalImage);
    
    
        // Check if the image was captured from the camera
        if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {
            // Save the image to the camera roll
            UIImageWriteToSavedPhotosAlbum(imageToSave, nil, nil, nil);
        }
    
        NSString *docspath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
        NSString *filepathJPG = [docspath stringByAppendingPathComponent:@"imagefile.jpg"];
    
        NSData *data = UIImageJPEGRepresentation(imageToSave, 0.8);
        BOOL result = [data writeToFile:filepathJPG atomically:YES];
        NSLog(@"Saved to %@? %@", filepathJPG, (result? @"YES": @"NO") );
    
        [picker dismissModalViewControllerAnimated:YES];
    }
    

    Then in your other view controller, wherever you would expect to load the image (viewDidLoad, viewWillAppear or wherever) put:

    NSString *docspath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
    NSString *filepathJPG = [docspath stringByAppendingPathComponent:@"imagefile.jpg"];
    
    UIImage *img = [UIImage imageWithContentsOfFile: filepathJPG];
    if (img != nil) {
        // assign the image to the imageview, 
        myImageView.image = img;
    
        // Optionally adjust the size
        BOOL adjustToSmallSize = YES;
        CGRect smallSize = (CGRect){0,0,100,100};
        if (adjustToSmallSize) {
            myImageView.bounds = smallSize;
        }
    
    }
    else {
        NSLog(@"Image hasn't been created");
    }
    

    Hope that helps

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I have this code to show image from folder in php : $handle
In my app i am using this code to get Image from Gallery and
I'm new to iPhone and I'm using this code to select an image from
Why this code show me a window without image? I try to use QByteArray
I wanted to show image from another server, but a smaller image maintaining the
I use until now this code for saving video that i get from UIImagePickerController
I got this issue with displaying a image that i allready have added as
I am using following code to choose image from camera role picker= [[UIImagePickerController alloc]
Hi I want to show an image from SD card. I have 10 images.
This is my code to present the UIImagePickerController: // Show the media browser with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.