[英]I am 5 Controllers deep into a Storyboard, how do I programmatically pop back to the Official Initial Controller?
I am 5 Controllers deep into a Storyboard, how do I programmatically and easily pop back to the Official Initial Controller? 我是情节提要中的5个控制器,我如何以编程方式轻松地弹出官方初始控制器?
Is there some one liner for this? 有一些衬板吗? What is the most elegant and simple solution? 什么是最优雅,最简单的解决方案?
1 - On your root VC, create an unwind method: something like: 1-在根VC上,创建一个展开方法:
- (IBAction)unwindToRoot:(UIStoryboardSegue*);
Then wire it up to "exit" in your storyboard. 然后将其连接到情节提要中的“退出”。 This is an unwind segue. 这是一场轻松的比赛。
or 2 - In your fifth VC, pop back manually: 或2-在第五个VC中,手动弹出:
[self.navigationController popToRootViewControllerAnimated:YES]
Indeed, there is a one-liner: 确实,有一条线:
[self.navigationController popToViewController:(UIViewController *)];
Of course you would replace (UIViewController *)
with the view controller at the beginning of the nav stack. 当然,您可以在导航堆栈的开头将(UIViewController *)
替换为视图控制器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.