Alessandro Pirovano
Alessandro Pirovano

Reputation: 2541

Received Memory Warning Storyboard

I have created a view controller that contains this code in viewDidLoad function:

[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View1"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View2"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View3"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View4"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View5"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View6"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View7"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View8"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View9"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View10"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View11"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View12"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View13"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View14"]];

When I open a new ViewController and I return to initial ViewController with this code:

UIViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"Home"];
vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:vc animated:YES completion:NULL];

I received memory warning.

Upvotes: 0

Views: 762

Answers (1)

jrturton
jrturton

Reputation: 119242

You're not returning to the home view controller there, you're creating a new instance of the home controller and presenting it. Do that enough times and you end up with a huge stack of controllers and a low memory situation.

Try dismissing your controller instead, though it isn't really clear from your question how you get to the VC with all the child controllers in it.

Upvotes: 2

Related Questions