简体   繁体   English

故事板-从模态视图控制器返回到选项卡栏控制器

[英]Storyboard - go back to tab bar controller from modal view controller

I have a tab bar controlled application. 我有一个标签栏控制的应用程序。

And I have a flow that goes something like this:- 我的流程像这样:-

Tab 1 View Controller (initial view controller) - "presented modally" View controller - "pushed" View Controller 2 - "pushed" View Controller 3 - "presented modally" View Controller 4

Basically, it is Modal - Push - Push - Modal 基本上是Modal - Push - Push - Modal

Now, I want to go back to Tab 1 View Controller(initial view controller) from View Controller 4 (that was presented modally). 现在,我想从View Controller 4(以模态形式显示)返回到Tab 1 View Controller(初始View Controller)。

View controller 4 should have a "back button" which when pressed will lead me back to Tab 1 View Controller. View Controller 4应该具有一个“后退按钮”,当按下该按钮时,它将带我回到Tab 1 View Controller。

How do I do that? 我怎么做? I tried:- 我试过了:-

  1. Creating a whole new UIWindow and placed things back. 创建一个全新的UIWindow并将其放回原处。 Problem is the back button which I placed on View Controller 4 comes back on Tab 1 View Controller. 问题是我放在View Controller 4上的后退按钮又回到了Tab 1 View Controller上。 Weird. 奇怪的。 Tried removing it with various methods, didn't go away. 尝试使用各种方法将其删除,但并没有消失。

  2. Use the popToViewController method, but the navigation controller is different because of last modal view controller. 使用popToViewController方法,但是导航控制器因最后一个模式视图控制器而有所不同。

Any clues on how to solve this? 关于如何解决这个问题的任何线索?

Okay so I solved it. 好吧,我解决了。 I needed to climb back down the ladder. 我需要爬下梯子。

Dismiss self.navigationController.presentingViewController.presentingViewController , which was pointing to UITabBarController , where self.navigationController is from View Controller no. 解雇self.navigationController.presentingViewController.presentingViewController ,其指向UITabBarController ,其中self.navigationController是从视图控制器没有。 4 (the last modal view controller). 4(最后一个模态视图控制器)。

You should try this on the button that leads to the first tab view controller 您应该在通向第一个标签视图控制器的按钮上尝试此操作

UIStoryboard *mySB = [UIStoryboard storyboardWithName:@"[StoryBoardFileName]" bundle:nil];
            UIViewController *vc = [mySB instantiateViewControllerWithIdentifier:@"[ViewControllerIdentifier]"];
            [self presentViewController:vc animated:YES completion:nil];

hope it helps 希望能帮助到你

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM