gpt4 book ai didi

ios - 如何弹出到 UITabBarItem 开关上的 Root View Controller ?

转载 作者:行者123 更新时间:2023-11-28 09:39:39 28 4
gpt4 key购买 nike

我有一个 UITabBarController 和两个 UINavigationController,当我从一个 TabBarItem 切换到另一个时,之前选择的 View Controller 应该弹出到它的 Root View Controller 。

最佳答案

像这样实现 UITabBarControllerDelegate tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) 方法:

func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
if let navigationController = viewController as? UINavigationController{
navigationController.popToRootViewController(animated: false)
}
return true
}

关于ios - 如何弹出到 UITabBarItem 开关上的 Root View Controller ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53429856/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com