Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IOS: dismiss two viewController

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?

like image 221
cyclingIsBetter Avatar asked Apr 18 '12 15:04

cyclingIsBetter


People also ask

How do you dismiss all presented view controller in Objective C?

e.g. root A -> Presents B -> Presents C and you want to dismiss to the A from C, you can officialy by calling dismissViewControllerAnimated on rootViewController . [[UIApplication sharedApplication]. delegate.

How do I dismiss a specific view controller in Swift?

Use unwind segue instead of using RootViewController. Using unwind you can go back to any ViewController. DismissViewController always send the controller out from NavigationController.


2 Answers

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];
 }
like image 107
rakeshNS Avatar answered Oct 04 '22 17:10

rakeshNS


How is the Third modal view being dismissed in the first place? Perhaps by the user touching a 'Done' button? If so, it is in the handler for the button that you want to dismiss both.

You can dismiss both as:

[self dismissModalViewControllerAnimated: YES];
[self.presentingViewController dismissModalViewControllerAnimated: NO];
like image 28
GoZoner Avatar answered Oct 04 '22 15:10

GoZoner