簡體   English   中英

我如何進入第一個窗口的第4個導航窗口(鈦iphone和android)?

[英]How i come 4th navigation window to first window (titanium iphone & android)?

我想逐個導航窗口4次,最后我想要一個窗口,然后我怎么來第一個窗口。 我怎么來到第一個窗口的第四個導航窗口

   var tabGroup        = Titanium.UI.createTabGroup();

var win1            = Titanium.UI.createWindow({

    backgroundColor : '#fff',
    navBarHidden    : true,
    orientationModes: [
        Titanium.UI.PORTRAIT,
    ]
});

var tab1            = Titanium.UI.createTab({
    title           : 'Menu',
    window      :  win1,
});
var btn         =Ti.UI.createButton({
    title           :"click",
    height      : "100",
    width       : "100",
});
win1.add(btn);
btn.addEventListener('click',function(){
    var win2            = Titanium.UI.createWindow({
        url     : "win2.js"
        backgroundColor : '#fff',
        navBarHidden    : true,
        orientationModes: [
            Titanium.UI.PORTRAIT,
        ]
    });

Ti.UI.currentTab.open(win2);



});

tabGroup.addTab(tab1);
tabGroup.open()

win2.js

var curwin = Ti.UI.currentWindow;
var btn         =Ti.UI.createButton({
    title           :"click",
    height      : "100",
    width       : "100",
});
curwin.add(btn);
btn.addEventListener('click',function(){
    var win3            = Titanium.UI.createWindow({
        url     : "win3.js"
        backgroundColor : '#fff',
        navBarHidden    : true,
        orientationModes: [
            Titanium.UI.PORTRAIT,
        ]
    });

Ti.UI.currentTab.open(win3);
});

win3.js

var curwin = Ti.UI.currentWindow;
var btn         =Ti.UI.createButton({
    title           :"click",
    height      : "100",
    width       : "100",
});
curwin.add(btn);
btn.addEventListener('click',function(){
    var win4            = Titanium.UI.createWindow({
        url     : "win4.js"
        backgroundColor : '#fff',
        navBarHidden    : true,
        orientationModes: [
            Titanium.UI.PORTRAIT,
        ]
    });

Ti.UI.currentTab.open(win4);
});

win4.js

var curwin = Ti.UI.currentWindow;
var btn         =Ti.UI.createButton({
    title           :"click",
    height      : "100",
    width       : "100",
});
curwin.add(btn);
btn.addEventListener('click',function(){
// Here I want to back First Window  how i can perform this iphone or android both
});

我怎么能這樣做?

Forging Titanium Episode 2中,他們開發了一個跨平台的導航控制器,在那里回到第一個窗口,他們存儲了他們在一個數組中打開的每個窗口,然后他們循環遍歷數組並關閉存儲在其中的所有窗口。 下面是他們對這個想法的一段代碼。

//go back to the initial window of the NavigationController
exports.NavigationController.prototype.home = function() {
    //store a copy of all the current windows on the stack
    var windows = this.windowStack.concat([]);
    for(var i = 1, l = windows.length; i < l; i++) {
        (this.navGroup) ? this.navGroup.close(windows[i]) : windows[i].close();
    }
    this.windowStack = [this.windowStack[0]]; //reset stack
};

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM