【问题标题】:How to disable UITabBarController如何禁用 UITabBarController
【发布时间】:2020-01-26 16:59:52
【问题描述】:

我有一个扩展UITabBarController 的标签和三个标签。如何禁止按条件打开选项卡?

class Tab: UITabBarController {

override func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {

        if(item.tag == 1) // dont open tab  ????
    }

}

【问题讨论】:

标签: ios swift uitabbarcontroller segue


【解决方案1】:

你可以的

class Tab: UITabBarController , UITabBarControllerDelegate{

    override func viewDidLoad() {
       super.viewDidLoad()
       self.delegate = self
    }
    func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
        return true / false // according to vc type 
     }
}

【讨论】:

  • 我需要覆盖吗?
  • 不只是符合UITabBarControllerDelegate内部viewDidLoad的委托
  • 我不懂你:(
  • 谢谢。你说的对。由于某种原因,我无法从 UITabBarControllerDelegate 继承
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-04-04
  • 2021-12-12
  • 1970-01-01
  • 1970-01-01
  • 2011-01-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多