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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:46:25+00:00 2026-06-13T13:46:25+00:00

I have two UIViewControllers in a storyboard (with a NavigationController ). I’m accessing the

  • 0

I have two UIViewControllers in a storyboard (with a NavigationController).

I’m accessing the camera and taking a picture in ViewController1. I want to switch to ViewController2 and display the captured picture in a UIImageView.

ViewController2 H file

@interface ViewController2 : UIViewController

{

-IBOutlet UIImageView *matchImage;

}

-(IBAction)restart:(id)sender;

@property (retain, nonatomic) UIImageView *matchImage;

@end

ViewController1 M file

After my code to take the picture I attempt to switch views using the following syntax

ViewController2 *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewController2"];

[self.navigationController pushViewController:vc animated:YES];

[vc.matchImage setImage:tempImage];

The first time I take a picture this works perfectly fine and I see the image in ViewController2.

However I have a back button on ViewController2 with the following syntax

ViewController2 M file

-(IBAction)restart:(id)sender

{

    ViewController1 *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewController1"];

    [self.navigationController pushViewController:vc animated:YES];

}

This successfully returns to ViewController1 and I’m able to take a picture again and repeat the process. But after about 3-4 times repeating the process I get Received Memory Warning and the app crashes. Running the Analyzer in Xcode yields no issues.

If I comment out the following line

[vc.matchImage setImage:tempImage];

Then I can perform endless captures (over 50 with no issues) but of course ViewController2 does not show an image (it is blank). So this led me to believe I need to release matchImage (especially because it is a property with a retain attribute). But this didn’t seem to help. Any help would be greatly appreciated. I’m still learning about memory management.

UPDATE

Here is a bit more info, after 3 iterations of back and forth switching between the views this is the debugger output. I put in NSLog statements in the two ViewController viewDidUnload and didReceiveMemoryWarning methods. So when the Received memory warning occurs it appears 3 “instances” of the 2 viewcontrollers are being unloaded. So it appears that for each iteration of switching between the viewcontrollers I’m getting a new copy. Is this what you would expect?

2012-10-22 08:23:32.008 TestApp[787:707] Received memory warning.

2012-10-22 08:23:32.015 TestApp[787:707] viewDidUnload ViewController1: 0xfd52250

2012-10-22 08:23:32.017 TestApp[787:707] didReceiveMemoryWarning ViewController1: 0xfd52250

2012-10-22 08:23:32.023 TestApp[787:707] viewDidUnload ViewController2

2012-10-22 08:23:32.025 TestApp[787:707] didReceiveMemoryWarning ViewController2

2012-10-22 08:23:32.028 TestApp[787:707] viewDidUnload ViewController1: 0x16dc30

2012-10-22 08:23:32.030 TestApp[787:707] didReceiveMemoryWarning ViewController1: 0x16dc30

2012-10-22 08:23:32.033 TestApp[787:707] viewDidUnload ViewController2

2012-10-22 08:23:32.037 TestApp[787:707] didReceiveMemoryWarning ViewController2

2012-10-22 08:23:32.040 TestApp[787:707] viewDidUnload ViewController1: 0x171de0

2012-10-22 08:23:32.042 TestApp[787:707] didReceiveMemoryWarning ViewController1: 0x171de0

2012-10-22 08:23:32.044 TestApp[787:707] didReceiveMemoryWarning ViewController2

2012-10-22 08:23:32.046 TestApp[787:707] didReceiveMemoryWarning ViewController1: 0xfd87580

  • 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-13T13:46:26+00:00Added an answer on June 13, 2026 at 1:46 pm

    What you’re doing in your restart method is not going back to your previous controller but adding another copy of the first controller type to the navigation stack. Try telling the navigation controller to popViewControllerAnimated: instead.

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

Sidebar

Related Questions

I have a simple storyboard consisting of two UIViewControllers, with a segue connecting them.
In my storyboard, i have two UIViewControllers both using the class CustomViewController. From the
I have two UIViewControllers, A and B, where A overrides the shouldAutorotateToInterfaceOrientation to return
I have two UIViewControllers that are contained in a navigatoin view controller and both
I have a two scene StoryBoard in my app - it uses an automatic
I have two UIViewControllers each with their own nib files. Each controller serves a
I have two UIViewControllers which I sometimes need to show at the same time.
I'm writing a simple checklist app. I have two UIViewControllers. The first displays the
I have an universal App with two storyboards: iPhone.storyboard iPad.storyboard Now I have views
I have a UIViewController in storyboard that includes a scrollView. I want to put

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.