在 Swift 中更改 ViewController 后禁用任务栏?

安卓版

我想以编程方式更改 ViewController 后禁用任务栏。我有一个悬停按钮。单击它后,将调用此代码来更改 ViewController:

self.navigationController?.setViewControllers([lvc!], animated: true)

这很好用。更改后,我正在调用 viewDidLoad 方法,该方法也被调用(检查控制台)。代码是这样的:

override func viewDidLoad() {
    super.viewDidLoad()
    self.tabBarController?.tabBar.isUserInteractionEnabled = false
}

该按钮位于 HomeView 中。如果我调用self.tabBarController?.tabBar.isUserInteractionEnabled = false HomeView 的 viewDidLoad 方法,则选项卡栏将被禁用。我正在使用 NavigationController 来呈现不同的视图。

知道为什么标签栏没有被禁用以及如何修复它吗?

哈沙

试试这个:

_ = tabBarController?.tabBar.items?.compactMap { $0.isEnabled = false }

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

在Windows 10中禁用任务栏

在Windows 7中禁用任务栏

在iOS8中使用Swift更改特定ViewController的状态栏颜色

在SWIFT中更改ViewController后如何保留集合视图滚动位置

Swift:ViewController中的TableView

Swift:从RESTful API进行身份验证后更改ViewController

在Ubuntu Gnome 13.10中禁用任务栏

在Windows 10中禁用任务栏预览

如何在任务栏中禁用Winamp代理?

如何在Swift中从AppDelegate更改ViewController中的文本标签?

Xcode:在 ViewController.swift 中禁用视图的旋转

下载后如何仅在Swift中显示ViewController?

使用 viewDidAppear() 在 swift5 中关闭另一个 ViewController 后刷新 ViewController

如何使用Swift在LaunchScreen中更改初始ViewController?

在Swift中更改ViewController类名称的正确方法是什么?

ViewController扩展中的Swift @IBActions

任务栏中的加号

在使用Swift展示新的Viewcontroller后,如何关闭以前的Viewcontroller?

在Swift中更改导航栏

在iOS Swift中获得顶级ViewController

将ViewController与Swift中的类型进行比较

如何使用Swift在iOS中关闭ViewController

从Swift中的UIButton选择到ViewController

如何在Swift中关闭ViewController?

在Swift 3中创建ViewController的单例

在Swift中的ViewController之间传递数组/对象

在Swift中从多个ViewController收集数据

在Swift中从AppDelegate获取ViewController的实例

在Swift中投射从UINavigationController中提取的viewController