0

我想逐个浏览窗口 4 次,最后我想进入 1 个窗口,然后我如何进入第一个窗口。我如何将第 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
});

我怎么能做到这一点?

4

1 回答 1

2

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
};
于 2012-06-04T19:29:53.427 回答