View Full Version : Dismissing Modal Views

Feb 17, 2009, 11:38 PM
How exactly do I dismiss a modal view controller at the bottom of the stack (to get back to the main screen) if I am currently in the topmost view of the stack?

Thanks for your help.

Feb 18, 2009, 12:04 AM
well, i figured out one way to do it, but if anyone has a better solution let me know:

My modal view stack goes 3 deep, so to get to the first one i just did:

[self.parentViewController.parentViewController dismissModalViewControllerAnimated:YES];

EDIT: well unfortunately if I try to go back into my Modal views, the views don't load. not sure what to do now...

Feb 18, 2009, 12:58 AM
From the Developer Documentation for dismissModalViewControllerAnimated:
If you dismiss a modal view controller in the middle or bottom of the stack, all the modal view controllers on top of that view controller are also dismissed. Use the modalViewController property before invoking this method if you need to retain the modal view controller.

Feb 19, 2009, 01:15 AM
alright i was on the right track before but now I think I figured it out

basically you just have to dismiss every single modal view starting with the bottom-most and then once all the modal view have been dismissed, you have to present the bottom one again. That will take you from the topmost modal view back to the first one.

Dec 7, 2009, 10:07 AM
Any chance you could put up the code for how you did this? Thanks