Ian Gray
Ian Gray

Reputation: 387

iOS: Switch view controller behind current modal view controller?

When I launch my app I'm presented with the root view controller (currently just a picture) which then pops up a modal view controller for the walk through. Once the user finishes the walk through, I want to dismiss the modal view controller and have the user be instantly presented with the main view controller for the app (rather than the root).

My issue is I can't figure out how to go about doing this. Currently all I can do is dismiss the modal back to the root, then switch the root view controller to the main one. This makes for a very ugly transition.

//WalkthroughViewController.m
-(void)completeWalkthrough:(UIButton *)sender {
   // What can I do here to switch the RootViewController
   // to display MainViewController ?
   [self dismissViewControllerAnimated:YES completion:nil];
}

Any help is appreciated. Thank you.

Upvotes: 1

Views: 1266

Answers (2)

user1459524
user1459524

Reputation: 3603

You could possibly achieve this with an Unwind Segue as well. In the Unwind Segue method of your Rootviewcontroller, present the Mainviewcontroller without delay.

Upvotes: 0

Tim
Tim

Reputation: 3434

Not sure if this would work, (it's late here) but I would possibly look into making the root view controller a delegate of the modal view.

Rather than dismissing the modal as you are doing now, pressing the 'completeWalThrough' button would call a delegate method. You could simultaneously dismiss the modal view and then push the main view controller from root View controller.

Upvotes: 1

Related Questions