[英]how to go to home page without storyboard by swift 4.2?
I have several viewcontrollers, and I want to have a work flow like below:我有几个视图控制器,我想要一个如下所示的工作流程:
So MainController will create a tabbarcontroller which include A,B,C view controller.所以 MainController 将创建一个包含 A、B、C 视图控制器的 tabbarcontroller。 Then when user goes to B, will go to B-1, B-2 then back to MainController at the final.
然后当用户转到 B 时,将转到 B-1、B-2,最后返回 MainController。
How can I do with this flow?我该如何处理这个流程? Should I use popViewController?
我应该使用 popViewController 吗? And if so, how ?
如果是这样,如何?
您可以使用它来弹出根视图控制器
self.navigationController?.popToRootViewController(animated: true)
In your case you need to work with UINavigationController .在您的情况下,您需要使用UINavigationController 。
Please check this example this example is perfect for your requirement.请查看此示例,此示例非常适合您的要求。
Apple example code (Objective-C) Apple 示例代码 (Objective-C)
Update Another example更新另一个例子
Here I am not put example code please check above links for your reference.这里我没有放示例代码,请查看上面的链接供您参考。
如果你不知道你的应用程序的层次结构,或者它太复杂了,这个可以让你得到你需要的UIViewController
。
let viewController = UIApplication.shared.keyWindow!.rootViewController as! YourViewController
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.