[英]Present ViewController modally from UITabBarController without hiding the tab bar
I have a UITabBarController
with 5 items in it. 我有一个
UITabBarController
有5个项目。 I have also a side menu with couple of items. 我还有一个带有几个项目的侧边菜单。 When tapping one of the items in the side menu I need to present view controller modally without hiding the tab bar.
当点击侧面菜单中的一个项目时,我需要以模态方式呈现视图控制器而不隐藏标签栏。 I tried the following:
我尝试了以下方法:
Presenting it from the selectedViewController
从
selectedViewController
呈现它
tabBarController.selectedViewController?.present(contactsViewController, animated: false, completion: {})
Presenting it from the UITabBarController
itself 从
UITabBarController
本身呈现它
tabBarController.present(contactsViewController, animated: true) {}
Adding a modal segue
in Storyboard from the selectedViewController to the contactsViewController and performing it 将Storyboard中的
modal segue
从selectedViewController添加到contactsViewController并执行它
All of these led to the tabBar being hidden. 所有这些导致tabBar被隐藏。 Is it possible to present the view controller modally without hiding the tab bar and how?
是否可以在不隐藏标签栏的情况下以模态方式呈现视图控制器?
You can use the UITabBarControllerDelegate
methods to present menu modally. 您可以使用
UITabBarControllerDelegate
方法以模态方式显示菜单。
func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool
{
if tabBarVC?.tabBar.selectedItem?.tag == 5
{
tabBarVC?.present(SideMenuManager.default.menuRightNavigationController!, animated: true, completion: nil)
return false
}
return true
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.