什么是隐藏在一个TabNavigator容器标签的最佳方式是什么?容器、标签、方式、TabNavigator

2023-09-08 12:12:17 作者:花落人憔悴

我想有条件地隐藏在一个TabNavigator容器标签。看来,设置明显的不正常工作(presumably因为这是如何与TabNavigator隐藏当前未选中的选项卡)。

I'd like to conditionally hide a tab in a TabNavigator. It seems that setting visible doesn't work properly (presumably because this is how the TabNavigator hides the tabs that aren't currently selected).

什么是正确的方式做到这一点?

What's the right way to do this?

推荐答案

您可以通过使用的TabNavigator的getTabAt()方法返回,构成了视觉选项卡按钮的做到这一点。然后,您可以设置该按钮的可见性。这是一个有点棘手得到这个设置了绑定,但它是可行的。

You can do this by making use of TabNavigator's getTabAt() method which returns the Button that makes up the visual tab. You can then set that Button's visible property. It's a little tricky to get this setup with a bindings, but it's doable.

您还可以考虑只禁用选项卡,而不是,您可以通过在相应的TabNavigator儿童(为其可见没工作)设置启用做的。

You could also consider just disabling the tab instead, which you can do by setting enabled on the corresponding TabNavigator child (for which visible didn't work).

 
精彩推荐
图片推荐