iOS: Switch view controller behind current modal v

2019-08-07 18:04发布

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.

2条回答
劫难
2楼-- · 2019-08-07 18:26

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

查看更多
霸刀☆藐视天下
3楼-- · 2019-08-07 18:38

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.

查看更多
登录 后发表回答