问题描述
启动我的应用程序时,我会看到根视图控制器(目前只有一张图片),然后弹出一个模态视图控制器以进行逐步操作。一旦用户完成遍历,我想关闭模态视图控制器,并立即向用户展示应用程序的主视图控制器(而不是根目录)。
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.
推荐答案
不确定这是否行得通,(现在晚了),但我可能会考虑制作根视图
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.
不是像现在那样关闭模态,而是按下 completeWalThrough按钮将调用一个委托方法。您可以同时关闭模式视图,然后从根视图控制器中推送主视图控制器。
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.
这篇关于iOS:将视图控制器切换到当前模式视图控制器之后?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!