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

标签 ios swift tabs navigation

我有以下 Storyboard:

enter image description here

如果用户导航到 View A1-2,然后选择选项卡 B,然后选择选项卡 A ... 他们将看到 TableViewController A1-2(他们最近的“选项卡 A 退出点”)。

如果他们导航到选项卡 B 然后决定“返回”并选择选项卡 A,我希望他们看到 TableViewController A1;不是他们之前导航到的地方(即 TableViewController A1-2,或他们最近的“Tab A 退出点”)。

基本上,任何选定的选项卡(当前选定的选项卡除外)都将显示该特定选项卡的 Root View Controller 。

我的 Storyboard设置是否可行?

非常非常感谢您的任何反馈。

附录:

我还可以在 View A1-2(或 A1-1、B1-2、B1-1)中使用以下代码吗:

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

    navigationController?.popToRootViewControllerAnimated(true)

}

如果用户切换标签页,那么有效地移除 Root View Controller 之上的所有 View ?并实现我想要的结果?

最佳答案

您可以在标签栏切换时关闭 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)
    }
}

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

关于ios - 显示 RootController 的 TabBar 项目 - 容器嵌入式 NavigationController TableViewController 堆栈,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37093437/

相关文章:

ios - 使用未解析的标识符 'boundingRect'

jQuery UI 选项卡动态添加选项卡和内容不起作用

android - 移动设备上的图像处理速度

iphone - 从应用程序编辑 iPhone 音乐 ID3 标签

ios - UIButton 和 UIScrollView - 按下按钮时滚动

ios - 从 TabViewController 中的 NavigationController 返回上一个 ViewController

windows - 如何在 vim 中映射 Shift-Tab? (Cygwin, Windows cmd.exe)

android - fragment 中的选项卡 View

ios - 无法在 Xcode 6.1/段错误 : 11 中存档工作 6.0.1 Swift 项目

ios - 为什么这个获取请求没有返回任何内容