首页 > 解决方案 > 以模态方式呈现 ViewController 时如何禁用所有 UITabBarItems?

问题描述

我已经在我的应用程序中实现了UITabBar。在一个 UITabBar 项目的 ViewController 中,我展示了另一个以模态方式呈现的 ViewController 。在这个阶段,我想禁用所有 UITabBar 项目并在willdisappear中重新启用。

在下面的委托中,如果我得到呈现的模态 ViewController,那么在比较时我可以返回而无需任何操作。但我对如何获得模态呈现的可见 ViewController 感到困惑。这种方法会奏效吗?

 (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController{
//HOW CAN I GET HERE VISIBLE VIEWCONTROLLER I.E. PRESENTED MODALLY VIEWCONTROLLER.
}

标签: iosobjective-cxcodeuitabbarcontrolleruitabbar

解决方案


禁用:

self.tabBarController.tabBar.userInteractionEnabled = NO;

使能够

self.tabBarController.tabBar.userInteractionEnabled = YES;

推荐阅读