2012-02-29 89 views
2

假设我有3个文件Window1.js,Window2.jsWindow3.js在多个钛窗之间导航

我可以从Window1导航到Window2和从Window2导航到Window3,没有问题。

当我想来自window3回到窗口2我做的:window3.close(); 现在我在窗口2,想回到窗口1,所以我所做的:window2.close();。但相反,我回到window3而不是我想要的window1。有没有办法回到window1?有人可以解释我如何在这个钛窗户之间导航?谢谢

+0

http://mobile.tutsplus.com/tutorials/appcelerator/drilldown-navigation-with-titanium/参考这个l在,可能会有帮助完整 – Triode 2012-02-29 08:34:35

回答

6

看看这个:the wiki提供了一个很酷的视频与example code。也许你可以提供一些可以验证你的问题..
这个例子本身是非常好的,因为它适用于任意数量的窗口。它提供了一个堆栈:

this.windowStack = []; 

该将要被filset window.navbarHidden =真或导致与当前窗口,窗口将一个navgroup内打开。这提供了在顶部的iphone导航栏(与后退按钮等)

this.windowStack.push(windowToOpen); 
this.navGroup.open(windowToOpen); 

的例子还提供了可能获得的第一个窗口,窗口1的。该堆栈将被刷新

for(var i = 1, l = windows.length; i < l; i++) { 
    (this.navGroup) ? this.navGroup.close(windows[i]) : windows[i].close(); 
} 

[更新]
如果你不感兴趣的导航栏只设置

window1.navbarHidden = true 

alternativly您可以编辑导航控制器是这样的:

exports.NavigationController.prototype.open = function(/*Ti.UI.Window*/windowToOpen) { 
    //add the window to the stack of windows managed by the controller 
    this.windowStack.push(windowToOpen); 

    //grab a copy of the current nav controller for use in the callback 
    var that = this; 
    windowToOpen.addEventListener('close', function() { 
     that.windowStack.pop(); 
    }); 

    //This is the first window 
    if(this.windowStack.length === 1 && (Ti.Platform.osname === 'android')) { 
     windowToOpen.exitOnClose = true; 
    } 

    // open 
    windowToOpen.open(); 
}; 
+0

问题是我不想要一个导航栏! – adrian 2012-03-01 07:54:05

+0

编辑我的答案。希望它有帮助 – mkind 2012-03-01 08:04:04

+0

你一直在这里? – adrian 2012-03-01 08:06:11