appcelerator:将新 window 推入模态 window

appcelerator: Pushing new window in to modal window

大家好,我有一个关于 Appcelerator 中模态视图的问题。目前,我在应用程序中显示了一个模态视图,带有导航 window(见下文)。

//this is my modal 
<Alloy>
    <NavigationWindow id="win1" platform="ios">
        <Window id="win2" title="Red Window" backgroundColor="red">

        </Window>
    </NavigationWindow>
</Alloy>

//this is the window i want to push in this modal view. 
<Alloy>
    <Window id="win3" title="Blue Window" backgroundColor="blue">
    </Window>
</Alloy>

在我的 win2.js(这是我的 parent window 也是我的模态)中,我有以下

var window = $.win2;
var navigationwindow = $.win1;

var button = Titanium.UI.createButton({
    title: 'Open Blue Window'
});

button.addEventListener('click', function(){
    navigationwindow.openWindow(win3, {animated:true});
});

但这没有任何作用。甚至可以在模态 window 中推送 windows 吗?

如果这里有人能帮助我,我将非常高兴。

openWindow() 推送新 window 的正确方法,但在您的 win2.js 控制器中 $ 变量将仅保留对您在 win2.xml 中创建的元素的引用,而不是您在其中创建导航 Window 的视图。在该视图的控制器中,添加一个引用,例如 Alloy.Globals.nav = $.win1(请务必在关闭导航 Window 后清理),然后您可以在 win2.js.

中使用它