视图导航器隐藏特定的标签不的TabBar [英] View Navigator Hide Specific Tab Not TabBar
问题描述
我试图找出是否有可能定义视图导航器并有选择地隐藏某些依赖于特定的用户状态?
I'm trying to figure out whether it is possible to define view navigators and selectively hide some depending on a particular user state?
例如我有两个导航选项卡其中之一是在标签的标志,另一个显示了用户的政策。我只希望政策选项卡,可以看到,如果用户在签署
For example I have two navigator tabs one which is a sign in tab and the other shows a users policy. I only want the policy tab to be visible if the user has signed in:
<s:ViewNavigator id="policyTab" width="100%" height="100%" firstView="views.policy.PoliciesView">
<s:navigationContent>
<s:Button id="policyTabButton" label="Policies" click="tabButton_clickHandler(event)" />
</s:navigationContent>
</s:ViewNavigator>
登录选项卡导航器:
Sign in tab is navigator:
<s:ViewNavigator id="signInTab" width="100%" height="100%" firstView="views.SignInView">
<s:navigationContent>
<s:Button id="signInTabButton" icon="@Embed('images/lockSmall.png')" click="tabButton_clickHandler(event)" />
</s:navigationContent>
</s:ViewNavigator>
一切,我已经研究指出我躲在我不希望做整个标签栏。我试着简单地调用signInTab.visible = FALSE;但不起作用。
Everything that I've researched points me to hiding the entire tab bar which I don't want to do. I've tried simply calling signInTab.visible = false; but is doesn't work.
任何帮助将是AP preciated。
Any help would be appreciated.
推荐答案
这是事实,你不能隐藏TabbedViewNavigator的内容,但有另一种方式来调整到隐藏的选项卡的内容。基本上你可以从TabbedViewNavigator删除该选项卡来隐藏它,并重新添加它再次显示。我想出了一个很简单的例子,似乎做什么你问。
It is true that you can't hide the contents of a TabbedViewNavigator, but there is another way to adjust the content to hide tabs. Basically you can remove the tab from the TabbedViewNavigator to hide it and re-add it to show it again. I've come up with a very simple example which seems to do what you are asking.
TabbedViewNavTest.mxml:
TabbedViewNavTest.mxml:
<?xml version="1.0" encoding="utf-8"?>
<s:TabbedViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
applicationDPI="160"
preinitialize="preinitializeHandler(event)">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
import views.Tab2View;
private static var app:TabbedViewNavigatorApplication;
public static function adjustTabBar():void {
if(app.navigators.length > 1) {
removeTab2();
} else {
addTab2();
}
}
private static function removeTab2():void {
app.tabbedNavigator.removeItemAt(1);
}
private static function addTab2():void {
var tab2:ViewNavigator = new ViewNavigator();
tab2.label = "Tab2";
tab2.percentWidth = 100;
tab2.percentHeight = 100;
tab2.firstView = Tab2View;
app.tabbedNavigator.addItemAt(tab2, 1);
}
protected function preinitializeHandler(event:FlexEvent):void {
app = this;
}
]]>
</fx:Script>
<s:ViewNavigator id="tab1" label="Tab1" width="100%" height="100%" firstView="views.Tab1View"/>
<s:ViewNavigator id="tab2" label="Tab2" width="100%" height="100%" firstView="views.Tab2View"/>
</s:TabbedViewNavigatorApplication>
Tab1View.mxml:
Tab1View.mxml:
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
title="Tab1">
<fx:Script>
<![CDATA[
protected function showHideButton_clickHandler(event:MouseEvent):void {
TabbedViewNavTest.adjustTabBar();
}
]]>
</fx:Script>
<s:Button id="showHideButton" label="Click Me!" click="showHideButton_clickHandler(event)" />
</s:View>
Tab2View是,当我创建的项目,创建只是一个空的观点。
Tab2View is just an empty view that was created when I created the project.
虽然这应该做你需要做的,我不知道是否有更好的方法来实现你正在尝试做的事。例如,在该情况下,你原来$登录选项卡当您在用户登录可能已经创建了您的应用程序有2个国家通用的应用程序,它消失的对$ psented:notLoggedIn和的loggedIn。在notLoggedIn状态下你只有一个视图显示,presents登录屏幕,还是有tabbedViewNavigator显示有登录和政策选项卡。在登录状态下,你有一个单独的tabbedViewNavigator其中只有政策选项卡或者其他选项卡时,登录用户使用。如果你要我创造了我的意思是一个例子,让我知道,我能做的这一点。
While this should do what you need it to do, I'm wondering if there is a better way to achieve what you are attempting to do. For instance, in the case you originally presented of a login tab which disappears when the user logs in you could have created your application as a generic application with 2 states: notLoggedIn and loggedIn. In the notLoggedIn state you only have a view show that presents the login screen, or have a tabbedViewNavigator show which has the login and policy tabs. In the logged in state, you have a separate tabbedViewNavigator which has only the policy tab or perhaps the other tabs available when a user is logged in. If you want me to create an example of what I mean, let me know and I can do that.
这篇关于视图导航器隐藏特定的标签不的TabBar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!