views:

104

answers:

2

So have a stack with three view controllers where A is root, B is first modal view controller and C is third modal vc. I would like to go from C to A at once. I have tried this solution to dismiss.It does work but not in a correct way. That is when the last view controller is dismissed it will breifly show the second view controller before the first is shown. What I'm looking for is a way to get from the third vc to the first in one nice animation without noticing the second view. Any help on this is greatly appriciated.

+1  A: 

What you want to use is popToRootViewControllerAnimated:. It gets you to the root controller without showing all the intervening ones.

lucius
That's a great solution if A is the root of a `UINavigationController`
ohhorob
Oh yeah. I just woke up, so I didn't catch that.
lucius
+2  A: 

Be sure that you're only calling dismissModalViewControllerAnimated: once.

I have found that asking to dismiss each stacked modal view controller will cause both of them to animate.

You have: A =modal> B =modal> C

You should only call [myViewControllerA dismissModalViewControllerAnimated:YES]

If you use [myViewControllerB dismissModalViewControllerAnimated:YES], it will dismiss C, and not B. In normal (unstacked) use, it would dismiss B (due to the responder chain bubbling the message up to A). In the stacked scenario that you describe B is a parent view controller and this takes precedence over being a modal view controller.

ohhorob
Well as of now I use:[[[self parentViewController] parentViewController] dismissModalViewControllerAnimated:YES];That would use the root viewcontroller. However, it still shows the second vc for a breif second.
sebrock
Oh, and I should say that I use the Utility template and the second vc is the flipside view. The third is a modal vc instantiated from the flipside.
sebrock