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 7833073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:33:16+00:00 2026-06-02T12:33:16+00:00

So I have a UIImageView on a view. The view also has a button

  • 0

So I have a UIImageView on a view. The view also has a button on it to pop a UIPickerViewController or camera controls. When someone selects an image, it sets the myImageView.image property and displays the image in my view. No saving of the image is done… it’s just a display of what you’ve chosen.

Sometimes, when I’m in UIPickerViewController, I get a memory warning. Because the picker is open, all of the other non-visble views, including my UIImageView, get released and viewDidLoad gets called again when the picker closes. This is as expected. But in the process I lose the image I was displaying as the image reverts back to it’s original “choose an image” image placeholder.

But how do I load the image that was in the UIImageView BEFORE the memory warning back into the UIImageView? Since it was in memory, it’s now lost. And I don’t know it’s location because the user picked it from the picker and I just took it straight from there with this:

itemImageView.image = [info objectForKey:UIImagePickerControllerOriginalImage];

Any ideas on how to recover that lost image? Or if I should save it in some variable or to the device to use again in case of a memory warning??

  • 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-02T12:33:17+00:00Added an answer on June 2, 2026 at 12:33 pm

    You need to retain a reference to the image as well as showing it in the UIImageView. e.g. save it in a property called selectedImage:

    .h:

    @property (nonatomic, retain) UIImage* selectedImage;
    

    Image picker delegate:

    self.selectedImage = [info objectForKey:UIImagePickerControllerOriginalImage];
    itemImageView.image = selectedImage;
    

    Then when itemImageView is unloaded (along with the rest of the view) due to low memory, you will still have the image retained. In viewDidLoad, check to see if you have an image that you should show:

    if (selectedImage != nil)
        itemImageView.image = selectedImage;
    

    Make sure you release selectedImage when it’s appropriate to do so for your app – e.g. when the user progresses beyond this screen, or when they cancel selecting this image, or when you save it out to the file system etc.

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

Sidebar

Related Questions

I have button created programmatically in the UIImageView. This view was also created programmatically.
i have a view with uiimageview i assign this uiimageview image by camera..now i
i have 2 views. A button and an UIimageView in view 1. In view
In my view I have few subviews. This is UIImageView. Each UIImageView contain image
I have a UIImageView which has a png image sequence loaded into it. My
I have a View Controller, and a UIImageView as a subview. That UIImageView also
I have a view with UIImageView and an image set to it. I want
I have an iPad application that has a base image UIImageView (in this case
I have an object that return a cached image view (UIImageView), which do the
I have two UIImageView objects inside my view (both 320x480 one above the other).

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.