0

In my app I am presenting many view one on the top of another.

So when I want to come out of all the views, I have to press cancel many times.

for example, HOME->OneViwe(modalView)->SubView(modalView).

How do I directly come to HOME from SubView?

Is there any way to directly come out from all the view?

Or can I dismiss one view after presenting another view? How?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Devang
  • 11,258
  • 13
  • 62
  • 100
  • You can also refer to [this](http://stackoverflow.com/questions/5935462/dismiss-modalviewcontroller-from-another-modalviewcontroller/5936872#5936872) post. –  Jun 25 '11 at 12:49
  • However, if you are popping modalView over modalView, you may want to question your current design modeL – Kheldar Aug 30 '11 at 09:43

2 Answers2

2

You can call dismissModalViewContorller on a view controllers parentViewController property. You can use the parentViewController hierarchy until the view controller you want to dismiss completely. If there are three modal view controllers in the hierarchy, your code should look like,

[self.parentViewController.parentViewController dismissModalViewControllerAnimated:YES];

EmptyStack
  • 51,274
  • 23
  • 147
  • 178
0

For a little more flexibility, check out the utility method I use for stuff like this here:

How to dismiss the two or more dismissModalViewController?

Community
  • 1
  • 1
Steve N
  • 2,667
  • 3
  • 30
  • 37