在钛制的多个窗口之间导航 [英] navigate between multiple windows in titanium

查看:51
本文介绍了在钛制的多个窗口之间导航的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有3个文件 Window1.js Window2.js Window3.js .

Let's assume I have 3 files Window1.js, Window2.js and Window3.js.

我可以毫无问题地从 Window1 导航到 Window2 ,从 Window2 导航到 Window3 .

I can navigate from Window1 to Window2 and from Window2 to Window3 with no problem.

当我想从window3返回window2时,我要做的是: window3.close(); 现在我在window2上,想回到window1,所以我做了: window2.close(); .但是,这反而使我回到了window3而不是我想要的window1.有什么办法可以回到window1吗?有人可以解释一下如何在钛制的这些窗口之间导航吗?谢谢

When I want to come back from window3 to window2 I do: window3.close(); Now I'm on window2 and want to go back to window1, so I did: window2.close();. But instead that got my back to window3 not to window1 as I wanted. Is there any way to get back to window1? Can someone explain me how to navigate between this windows in titanium?Thanks

推荐答案

对此进行了查看: Wiki 提供了一个很酷的视频,其中示例代码.也许您可以提供一些方法来验证您的问题..
该示例本身非常好,因为它适用于任意数量的窗口.它提供了一个堆栈:

have a look at this: the wiki provides a cool video with example code. maybe you can provide some could to validate your problem..
the example itself is very nice since it works great for an arbitary amount of windows. it provides a stack:

this.windowStack = [];

这将是filset window.navbarHidden = true或由当前窗口引导,该窗口将在navgroup中打开.这会在顶部提供iPhone导航栏(带有后退按钮等)

that is going to be filset window.navbarHidden = true or led with the current window and the window will be opened within a navgroup. this provides the iphone navigation bar at the top (with backbutton etc)

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

该示例还提供了获取第一个窗口(即window1)的可能性.为此,堆栈将被刷新

the example also provides the possibility to get the first window, your window1. for that the stack will be flushed

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

[更新]
如果您对导航栏不感兴趣,只需设置

[update]
if you are not interested in the navbar just set

window1.navbarHidden = true

或者,您可以像下面这样编辑导航控制器:

alternativly you can edit the navigation controller like this:

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

这篇关于在钛制的多个窗口之间导航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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