在UIStoryboard中按下到根视图控制器 [英] Push to root View controller in UIStoryboard
问题描述
我的故事板结构中有 ViewControllers
的层次结构。
A-B-C-D 。 A 嵌入了 NavigationController
,流程一直持续到 D viewController
。所有四肢视图通过segues附加。现在我在 D viewController
,我在 D 的按钮上定义了一些操作,它应该直接带我到 A viewController
即 rootViewController
或 B 的viewController
。那怎么能实现这一点呢。我尝试了一切,但没有成功。
I have hierarchy of ViewControllers
in my storyboard structure.
It is A-B-C-D. A is embed with NavigationController
and the flow goes on till D viewController
. All fours view attached through segues. Now I am on D viewController
, I defined some action to the button of D that It should take me directly to A viewController
that is rootViewController
or B viewController
. Then how can I achieve this. I tried everything but didn't succeed.
我想要的东西应该不会打扰 ABCD 流程,它应该带我去 D 的 viewController
。
I want something like it should not disturb A-B-C-D flow and it should take me to A viewController
from D.
推荐答案
右键单击D viewcontroller并将i拖到A viewcontroller。
Right click on your D viewcontroller and drag i to your A viewcontroller.
然后单击刚刚创建的行上显示的对象。
Then click on the object which appears on the line you just created.
在属性检查器中的storyboard segue标识符中写入类似DtoA的内容。
Write something like DtoA in the storyboard segue identifier in the attributes inspector.
现在在D视图控制器中,只需:
Now in D view controller, just do:
[self performSegueWithIdentifier:@"DtoA" sender:self];
如果您希望以旧式方式弹出以前的viewcontroller,例如从D到B :
And if you instead wish to pop to a previous viewcontroller the old fashioned way, like from D to B:
UINavigationController* navController = self.navigationController;
UIViewController* Bviewcontroller = [navController.viewControllers objectAtIndex:1];
[navController popToViewController:controller animated:YES];
我希望这有帮助!
这篇关于在UIStoryboard中按下到根视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!