在swift4中切换选项卡Tabbar控制器

问题描述

我尝试将tab2切换到tab1,而不在swift4中重定向主页。 示例:我的应用程序包含三个选项卡(选项,历史记录,更多)。在“选项”选项卡中,选项卡栏顶部的按钮用于导航OptionsDetailViewController。我单击并导航到OptionsDetailViewController,然后切换到“历史记录”选项卡,然后切换到“选项”选项卡,然后显示“ OptionsDetailViewController”,但需要“选项”选项卡主页。

class TabbarViewController: UITabBarController {
    override func viewDidLoad() {
        super.viewDidLoad()
        self.delegate = self
    }
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
                viewControllers?.compactMap{ ($0 as? UINavigationController)?.visibleViewController }.forEach {
                    $0.navigationController?.navigationBar.isTranslucent = false
                    $0.navigationController?.navigationBar.tintColor = UIColor.white
                }
    }
}

extension TabbarViewController: MoveableAnimation {
    
    func transitionDuration() -> CFTimeInterval {
        return 0.4
    }
    
    func transitionTimingFunction() -> camediatimingFunction {
        return .easeInOut
    }
    
    func fromTransitionAnimation(layer: CALayer,direction: Direction) -> CAAnimation {
        return DefineAnimation.move(.from,direction: direction)
    }
    
    func toTransitionAnimation(layer: CALayer,direction: Direction) -> CAAnimation {
        return DefineAnimation.move(.to,direction: direction)
    }
    
    func tabBarController(_ tabBarController: UITabBarController,shouldSelect viewController: UIViewController) -> Bool {
        return animateTransition(tabBarController,shouldSelect: viewController)
    }
}

要求:我的应用程序包含三个标签(选项,历史记录,更多)。在“选项”选项卡中,选项卡栏顶部的按钮用于导航OptionsDetailViewController。我单击并导航到OptionsDetailViewController,然后切换到“历史记录”选项卡,然后切换到“选项”选项卡,然后显示“ OptionsDetailViewController”,但需要“选项”选项卡主页。

我介绍了博客,但没有解决我的问题。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)