显示 RootController 的 TabBar 项目 - 容器嵌入式 NavigationController TableViewController 堆栈

TabBar Item To Show RootController - Container-Embedded NavigationController TableViewController Stacks

我有以下故事板:

如果用户导航到视图 A1-2,然后 selects 选项卡 B,然后 selects 选项卡 A ... 他们将看到 TableViewController A1-2(他们最近的 "Tab A exit point").

如果他们导航到选项卡 B 然后决定 'go back' 和 select 选项卡 A,我希望他们看到 TableViewController A1;不是他们之前导航到的地方(即 TableViewController A1-2,或他们最近的 "Tab A exit point")。

基本上,任何 selected 选项卡(当前 selected 选项卡除外)都将显示该特定选项卡的根视图控制器。

我的情节提要设置是否可行?

非常非常感谢任何反馈。

附录:

我是否也可以在视图 A1-2(或 A1-1、B1-2、B1-1)中使用以下代码:

override func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(animated)

    navigationController?.popToRootViewControllerAnimated(true)

}

如果用户切换标签页,那么有效地移除根视图控制器之上的所有视图?并达到我想要的结果?

您可以在标签栏切换时关闭 A1-2 和 A1-1,如果需要,反之亦然。

//set tab bar delegate and call this method
func tabBar(tabBar: UITabBar, didSelectItem item: UITabBarItem) {
    if item == tabBarB {
        //dismiss viewController A1-2 and A1-1
        self.view.window!.viewControllerA1?.dismissViewControllerAnimated(false, completion: nil)
    } else {
        //dismiss miss viewController B1-2 and B1-1
        self.view.window!.viewControllerB1?.dismissViewControllerAnimated(false, completion: nil)
    }
}

如果这就是您要找的,请告诉我。