灵活移动TabbedViewNavigatorApplication后退按钮 [英] flex mobile TabbedViewNavigatorApplication back button

查看:229
本文介绍了灵活移动TabbedViewNavigatorApplication后退按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么 TabbedViewNavigatorApplication 没有popView()(如 ViewNavigatorApplication 我可以使用popView去前视图)?



如何在 TabbedViewNavigatorApplication 中执行此操作?

 < fx:Script> 
<![CDATA [
protected function BackBtn(event:MouseEvent):void {
navigator.popView(); //错误
}
]]>
< / fx:Script>

< s:titleContent>
< s:Button label =Backclick =BackBtn(event)/>
< / s:titleContent>
< / s:ViewNavigator>
< / s:TabbedViewNavigatorApplication>

谢谢。

解决方案

 <?xml version =1.0encoding =utf-8?> 
xmlns:fx =http://ns.adobe.com/mxml/2009
xmlns:s =library ://ns.adobe.com/flex/spark>
< fx:Script>
<![CDATA [
import mx.events.FlexEvent;

导入spark.events.IndexChangeEvent;

private var tabHistory:Array;
private var isLoadingFromHistory:Boolean;
$ b保护函数BackBtn(event:MouseEvent):void
{
isLoadingFromHistory = true;
if(tabHistory.length == 0)
{
trace(你不能再回头了);
tabHistory.push(0);
}
tabbedNavigator.selectedIndex = tabHistory.pop();


保护函数tabbedviewnavigatorapplication1_creationCompleteHandler(event:FlexEvent):void
{
tabHistory = [];
tabbedNavigator.addEventListener(IndexChangeEvent.CHANGE,tabsChangedHandler);

$ b private function tabsChangedHandler(event:IndexChangeEvent):void
{
if(isLoadingFromHistory)
{
isLoadingFromHistory = false;
return;
}
tabHistory.push(event.oldIndex);
trace(tabHistory);
}
]]>
< / fx:Script>

height =100%
label =Page1
width =100%> ;
< s:titleContent>
label =Back/>
< / s:titleContent>
< / s:ViewNavigator>
height =100%
label =Page2
width =100%>
< s:titleContent>
label =Back/>
< / s:titleContent>
< / s:ViewNavigator>
< / s:TabbedViewNavigatorApplication>


Why TabbedViewNavigatorApplication don’t have popView() (as in ViewNavigatorApplication I can use popView to go previous view)?

How can I do that in TabbedViewNavigatorApplication?

    <fx:Script>
    <![CDATA[      
      protected function BackBtn(event:MouseEvent):void{
        navigator.popView(); //error
      }
    ]]>
  </fx:Script>

<s:ViewNavigator label="Page1" width="100%" height="100%" firstView="views.DurationView" >
    <s:titleContent>
      <s:Button label="Back" click="BackBtn(event)"/>
    </s:titleContent>
  </s:ViewNavigator>
<s:ViewNavigator label="Page2" width="100%" height="100%" firstView="views.FrequencyView"/>
</s:TabbedViewNavigatorApplication>

thanks.

解决方案

<?xml version="1.0" encoding="utf-8"?>
<s:TabbedViewNavigatorApplication creationComplete="tabbedviewnavigatorapplication1_creationCompleteHandler(event)"
                                  xmlns:fx="http://ns.adobe.com/mxml/2009"
                                  xmlns:s="library://ns.adobe.com/flex/spark">
    <fx:Script>
        <![CDATA[
            import mx.events.FlexEvent;

            import spark.events.IndexChangeEvent;

            private var tabHistory : Array;
            private var isLoadingFromHistory : Boolean;

            protected function BackBtn(event : MouseEvent) : void
            {
                isLoadingFromHistory = true;
                if (tabHistory.length == 0)
                {
                    trace("You can't go back any further");
                    tabHistory.push(0);
                }
                tabbedNavigator.selectedIndex = tabHistory.pop();
            }

            protected function tabbedviewnavigatorapplication1_creationCompleteHandler(event : FlexEvent) : void
            {
                tabHistory = [];
                tabbedNavigator.addEventListener(IndexChangeEvent.CHANGE, tabsChangedHandler);
            }

            private function tabsChangedHandler(event : IndexChangeEvent) : void
            {
                if (isLoadingFromHistory)
                {
                    isLoadingFromHistory = false;
                    return;
                }
                tabHistory.push(event.oldIndex);
                trace(tabHistory);
            }
        ]]>
    </fx:Script>

    <s:ViewNavigator firstView="views.WhosAtTheDoorHomeView"
                     height="100%"
                     label="Page1"
                     width="100%">
        <s:titleContent>
            <s:Button click="BackBtn(event)"
                      label="Back"/>
        </s:titleContent>
    </s:ViewNavigator>
    <s:ViewNavigator firstView="views.WhosAtTheDoorHomeViewCopy"
                     height="100%"
                     label="Page2"
                     width="100%">
        <s:titleContent>
            <s:Button click="BackBtn(event)"
                      label="Back"/>
        </s:titleContent>
    </s:ViewNavigator>
</s:TabbedViewNavigatorApplication>

这篇关于灵活移动TabbedViewNavigatorApplication后退按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆