Reputation: 9376
I have a very screwed up view system going on. I go through a couple of modal views and then want to jump back to my original view (looping back on itself). Only problem is that it keeps allocating new views on top of others until I run out of memory and the app crashes. How do I tell my app that I am never coming back to the previews view controller and that it should release the memory blocks? I want to do something like this: self.presentingViewController = nil; But it's read only and the more I think about it just can't work like that. Here is my storyboard.
Upvotes: 0
Views: 485
Reputation: 69027
It is not entirely clear what you are doing and why it does not work as you expect, but I think that the following approach should work for you:
I start at the "root table view" then I do a modal
*then from the view with the "placehold" text I modal to the game controller
then I want to modal back to the navcontroller/root table view.
I assume that you are doing 1. and 2 using – presentViewController:animated:completion:
(or the now deprecated – presentModalViewController:animated:
).
In order to do 3., you have to call:
[self.presentingController dismissViewControllerAnimated:ZZZ completion:nil];
This will dismiss all the modal view controllers from the root table view down to the one you are dismissing.
If you are already doing this and it does not work as you want, I think it could be because you are dismissing the modal view controllers and the presenting a new one within the same run loop cycle. To get around this, simply define a method in your root controller, say:
- (void)presentFirstViewController {
[self presentViewController:xxxxx animated:YES completion:nil];
}
later you dismiss the modal controller doing:
self.presenting.Controller dismissViewControllerAnimated:YES completion:nil];
and present the new one doing:
[rootController performSelector:@selector(presentFirstViewController) withObject:nil afterDelay:0.0];
This last step would provide some time for the run loop to clean up things when dismissing, and successively present the modal controller.
Hoper this helps.
Upvotes: 1