当从选项卡栏控制器的主页转到详细视图时,我希望选项卡栏保持可见,并且“主页”选项卡显示为活动状态
// In your main view controller where the tab bar is managed
func navigateToDetail(subspaceId: Int, subspaceType: String,
channelType: ThreadsType, channelName: String)
{
let vc = SubSpaceHomeRouter.setupModule(subspaceId: subspaceId, subspaceType: subspaceType, channelType: channelType, channelName: channelName)
vc.hidesBottomBarWhenPushed = false
// Present the detail view controller
view?.present(vc, animated: true)
}
// In the function where you configure the "Home" tab view controller
private func getCompanyHomeViewController() -> HomeViewController {
let controller = HomeRouter.setupModule(userId: presenter?.retrieveCurrentUserId() ?? 0,
companyId: presenter?.getSpaceId() ?? 0, isThisHomePage: true)
// Set tab bar item
controller.tabBarItem = createTabBarItem(icon:
UIImage(named: "icon_home")?.withRenderingMode(UIImage.RenderingMode.alwaysOriginal),
title: "edit_home".localized,
isProfile: true)
return controller
}
如何在 Swift 中导航到详细信息而不隐藏选项卡栏并使其保持为“Home”可见
在要隐藏选项卡的控制器中,在该控制器中添加以下代码
viewWillAppear
self.tabBarController?.tabBar.isHidden = false
并且您不想隐藏哪个控制器,在该控制器中添加以下代码
viewWillAppear
self.tabBarController?.tabBar.isHidden = true