IOS: dismiss two viewController

cyclingIsBetter picture cyclingIsBetter · Apr 18, 2012 · Viewed 11.1k times · Source

I have three viewController

First, Second and Third

from Second to open Third I use

Third *third = [[Third alloc]initWithNibName:@"Third" bundle:nil];
[self presentModalViewController:third animated:YES];
[third release];

Now I want return from third to first; then I set in viewDidAppear in second this code:

[self dismissModalViewControllerAnimated:NO];

but for 1 second I see Second and I don't want watch it...how can I do?

Answer

rakeshNS picture rakeshNS · Apr 18, 2012

You need to dismiss third view controller first and then second Viewcontroller. Do the following code when you want to go first view controller.

-(void)goToFirstView{
        UIViewController *vc = [self parentViewController];
   //     UIViewController *vc = [self presentingViewController]; //ios 5 or later
        [self dismissModalViewControllerAnimated:NO];
        [vc dismissModalViewControllerAnimated:YES];
 }