Ios 我怎样才能隐藏一个修道院院长?
我目前正在开发一个iOS应用程序,它将有5个选项卡图标。其中一个应该只有在允许您查看的情况下才可见。Ios 我怎样才能隐藏一个修道院院长?,ios,swift,uitabbarcontroller,uitabbar,uitabbaritem,Ios,Swift,Uitabbarcontroller,Uitabbar,Uitabbaritem,我目前正在开发一个iOS应用程序,它将有5个选项卡图标。其中一个应该只有在允许您查看的情况下才可见。 如何隐藏此图标?使用以下代码,您可以从选项卡栏中删除指定的选项卡: let tabIndex = 3 if let tabBarController = self.tabBarController { if tabIndex < tabBarController.viewControllers?.count { var allViewControllers = ta
如何隐藏此图标?使用以下代码,您可以从选项卡栏中删除指定的选项卡:
let tabIndex = 3
if let tabBarController = self.tabBarController {
if tabIndex < tabBarController.viewControllers?.count {
var allViewControllers = tabBarController.viewControllers
allViewControllers?.remove(at: tabIndex)
tabBarController.viewControllers = allViewControllers
}
}
让tabIndex=3
如果让tabBarController=self.tabBarController{
如果tabIndex
如果要从tabBar
中删除UIViewController
,请将此行代码添加到UIAbbarController类中
移除
self.viewControllers?.remove(at:tabIndex)//替换要删除的tabIndex
添加
self.viewControllers?.insert(viewController,at:tabIndex)//用控制器替换viewController,用索引替换tabIndex
您可以在运行时添加/删除tabBarItems以实现此目的。self.tabBarController?.tabBar.hidden=true/false@BhavikModi我该怎么做?@YogeshPatel这会隐藏整个tabbar,而不是一个特定的图标。好的,试试这种方法tabbar控制器。viewControllers?删除(位于:0)我使用self.tabBarController?.viewControllers?
在ViewController中完成了该操作,而不是在UITABBARController类中。这也行得通。