简体   繁体   中英

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

I want to navigate window one by one 4 time and lastly i want to come 1 window then how i come first window. How i come 4th navigation window to first window

   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
});

How I can perform this?

In Forging Titanium Episode 2 they developed a cross-platform navigation controller where to back to first window they stored each window they open in an array, then they loop through the array and close all windows stored in it. Below a piece of code from them of this idea.

//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
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM