View 窗口间的合金导航

View 窗口间的合金导航,view,window,titanium,appcelerator,View,Window,Titanium,Appcelerator,我有3个带合金加速装置的屏幕: index.xml welcome.js我想打开列表窗口 当我点击索引标签打开欢迎窗口时,当我点击欢迎视图时,它什么也不做,我的目标是发现如何使用alloy在多个窗口视图文件之间导航 其次,我在谷歌上看到,关闭以前的窗口是一种很好的做法,如下所示: $.win.close(); $.win = null; 当我在$.win.open之后将此代码放在index.js中时,它不起作用,即:我出错了 function doClick(e) { var win = Al

我有3个带合金加速装置的屏幕:

index.xml

welcome.js我想打开列表窗口

当我点击索引标签打开欢迎窗口时,当我点击欢迎视图时,它什么也不做,我的目标是发现如何使用alloy在多个窗口视图文件之间导航

其次,我在谷歌上看到,关闭以前的窗口是一种很好的做法,如下所示:

$.win.close();
$.win = null;
当我在$.win.open之后将此代码放在index.js中时,它不起作用,即:我出错了

function doClick(e) {
var win = Alloy.createController("bienvenue").getView();
win.open();
$.win.close(); // or win.close() ?
$.win = null; // or win = null ?
}
有什么建议吗?我试了很多次都没有成功


谢谢大家。

关于亲密关系的良好实践,是和否

如果您希望当用户使用“后退”按钮返回时窗口在那里,则不需要,因为本质上,它将被关闭

function doClick(e) {
 var win = Alloy.createController("bienvenue").getView();
    win.open();
    $.win.close(); // DEFINITELY $.win, as you created a var named win for your new window
    $.win = null; // and $.win is the equivalent of findViewById("win")
}
顺便说一句,你打开windows的方式,你将无法利用Android中的导航硬件,iOS导航中的导航软件

对于Android,我通常会编写自己的管理器来确定当前哪个窗口有焦点,以及返回时会发生什么

对于iOS,您应该使用类似的方法将窗口序列添加到导航部分

var controllerWindow = Alloy.createController("bienvenue") // changed win to controllerWindow for clarity


var nav = Titanium.UI.iOS.createNavigationWindow({
                   window: controllerWindow
                });
nav.open();

我相信你想要的答案是如何在打开一个新窗口的同时关闭上一个窗口(触发动作的窗口)


您的示例只是创建并打开一个新窗口。然后关闭它。您需要做的是关闭上一个窗口。如果您为上一个窗口提供了一个id,那么您可以使用$.id.close关闭is。

是否有任何知名且经过测试的库可以跨平台为我这样做?
function showTable(e){
var liste = Alloy.createController("liste");
liste.getView().open();
}
$.win.close();
$.win = null;
function doClick(e) {
var win = Alloy.createController("bienvenue").getView();
win.open();
$.win.close(); // or win.close() ?
$.win = null; // or win = null ?
}
function doClick(e) {
 var win = Alloy.createController("bienvenue").getView();
    win.open();
    $.win.close(); // DEFINITELY $.win, as you created a var named win for your new window
    $.win = null; // and $.win is the equivalent of findViewById("win")
}
var controllerWindow = Alloy.createController("bienvenue") // changed win to controllerWindow for clarity


var nav = Titanium.UI.iOS.createNavigationWindow({
                   window: controllerWindow
                });
nav.open();