iOS: Switch view controller behind current modal view controller?

一曲冷凌霜 提交于 2019-12-11 06:58:52

问题


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.


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/22184826/ios-switch-view-controller-behind-current-modal-view-controller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!